Text File Input

Onboarding text files ..

Some of the Orders data that Steel Wheels process are in a text format. In this guided demo, you will flatten the list, create capture groups, replace text, and finally format the order_value.

In this Lab, you will configure the following steps:

• Text File Input

• Flattener

• RegEx Evaluation

• Replace in String

• Select values

The lab gives you an idea of some of the steps required to load flat files into a database table.

Lets take a look at the data, which will give us an idea of how to approach a possible solution.

• each line is a record

• 3rd line is 2 records: 'order status' & 'order date'

• Order Value: in $

• white space

So what do we need to do to get this into a database table?

• Flatten rows

• Extract values and associated with new data stream fields

• String cut

• Format fields - Date / Order Value


To create a new transformation

  1. In Spoon, click File > New > Transformation.

Any one of these actions opens a new Transformation tab for you to begin designing your transformation.

  • By clicking New, then Transformation

  • By using the CTRL-N hot key

File: /home/installer/Workshop--Data-Integration/Module 2 - Working with Flat Files/Lab 1 - Read Text File

The Text File Input step is used to read data from a variety of different text-file types. The most commonly used formats include Comma Separated Values (CSV files) generated by spreadsheets and fixed width flat files.

The Text File Input step provides you with the ability to specify a list of files to read, or a list of directories with wild cards in the form of regular expressions. In addition, you can accept filenames from a previous step making filename handling more even more generic.

  1. Drag the ‘Text File Input’ step onto the canvas.

  2. Double-click on the step, and configure the following properties:

Because the sample file is located in the same directory where the transformation resides, a good approach to naming the file in a way that is location independent is to use a system variable to parameterize the directory name where the file is located. In our case, the complete filename is:

${Internal.Transformation.Filename.Directory}/orders.txt

  1. Click on the ‘Content’ tab and configure the following properties:

  1. Click on ‘Get Fields’ button.

Click on the ‘Fields’ tab and notice the following properties:

The dataset is associated with ‘Field1’ with a data type of String, in the data stream.

  1. Close the Step.

➡️ Next: Flatten the rows

Last updated