Chapter 2. Reading and Writing Files

In this chapter, we will cover:

  • Reading a simple file
  • Reading several files at the same time
  • Reading unstructured files
  • Reading files having one field by row
  • Reading files having some fields occupying two or more rows
  • Writing a simple file
  • Writing an unstructured file
  • Providing the name of a file (for reading or writing) dynamically
  • Using the name of a file (or part of it) as a field
  • Reading an Excel file
  • Getting the value of specific cells in an Excel file
  • Writing an Excel file with several sheets
  • Writing an Excel file with a dynamic number of sheets

Introduction

Files are the most primitive, but also the most used format to store and interchange data. PDI has the ability to read data from all kind of files and different formats. It also allows you to write back to files in different formats as well.

Reading and writing simple files is a very straightforward task. There are several steps under the input and output categories of steps that allow you to do it. You pick the step, configure it quickly, and you are done. However, when the files you have to read or create are not simple—and that happens most of the time—the task of reading or writing can become a tedious exercise if you don't know the tricks. In this chapter, you will learn not only the basics for reading and writing files, but also all the how-tos for dealing with them.

Note

This chapter covers plain files (txt, csv, fixed width) and Excel files. For recipes for reading and writing XML files, refer to Chapter 3, Manipulating XML Structures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.166.149