This scenario describes a four-component Job that reads data from a positional file, writes the data to another positional file, and replaces the padding characters with space. The schema column details are not defined in the positional file components; instead, they leverages a reusable dynamic schema. The input file used in this scenario is as follows:
id----name--------city-------- 1-----Andrews-----Paris------- 2-----Mark--------London------ 3-----Marie-------Paris------- 4-----Michael-----Washington--
Drop the following components from the Palette onto the design workspace: tFixedFlowInput, tSetDynamicSchema, tFileInputPositional, and tFileOutputPositional.
Connect the tFixedFlowInput component to the tSetDynamicSchema using a Row > Main connection to form a subjob. This subjob will define a reusable dynamic schema.
Connect the tFileInputPositional component to the tFileOutputPositional component using a Row > Main connection to form another subjob. This subjob will read data from the input positional file and write the data to another positional file based on the dynamic schema set in the previous subjob.
Connect the tFixedFlowInput component to the tFileInputPositional component using a Trigger > On Subjob Ok connection to link the two subjobs together.
Double-click the tFixedFlowInput component to show its Basic settings view and define its properties.
Click the [...] button next to Edit schema to open the [Schema] dialog box.
Click the [+] button to add three columns: ColumnName, ColumnType, and ColumnLength, and set their types to String, String, and Integer respectively to define the minimum properties required for a positional file schema. Then, click OK to close the dialog box.
Select the Use Inline Table option, click the [+] button three times to add three lines, give them a name in the ColumnName field, according to the actual columns of the input file to read: ID, Name, and City, set their types in the corresponding ColumnType field: id_Interger for column ID, and id_String for columns Name and City, and set the length values of the columns in the corresponding ColumnLength field. Note that the column names you give in this table will compose the header of the output file.
Double-click the tSetDynamicSchema component to open its Basic settings view.
Click Sync columns to ensure that the schema structure is properly retrieved from the preceding component.
Under the Parameters table, click the [+] button to add three lines in the table.
Click in the Property field for each line, and select ColumnName, Type, and Length respectively.
Click in the Value field for each line, and select ColumnName, ColumnType, and ColumnLength respectively.
Now, with the values set in the inline table of the tFixedFlowInput component retrieved, the following data structure is defined in the dynamic schema:
Column Name Type Length ID Integer 6 Name String 12 City String 12
Double-click the tFileInputPositional component to open its Basic settings view.
The dynamic schema feature is only supported in Built-In mode and requires the input file to have a header row.
Select the Use existing dynamic check box, and in from the Component List that appears, select the tSetDynamicSchema component you use to create the dynamic schema. In this use case, only one tSetDynamicSchema component is used, so it is automatically selected.
In the File name/Stream field, enter the path to the input positional file, or browse to the file path by clicking the [...] button.
Fill in the Header, Footer and Limit fields according to your input file structure and your need. In this scenario, we only need to skip the first row when reading the input file. To do this, fill the Header field with 1 and leave the other fields as they are.
Click the [...] button next to Edit schema to open the [Schema] dialog box, define only one column, dyn in this example, and select Dynamic from the Type list. Then, click OK to close the [Schema] dialog box and propagate the changes.
Select the Customize check box, enter
'-'in the Padding char field, and keep the other settings as they are.
Double-click the tFileOutputPositional component to open its Basic settings view.
Select the Use existing dynamic check box, specify the output file path, and select the Include header check box.
In the Padding char field, enter
' 'so that the padding characters will be replaced with space in the output file.
Press Ctrl+S to save your Job to ensure that all the configured parameters take effect.
Press F6 or click Run on the Run tab to execute the Job.
The data is read from the input positional file and written into the output positional file, with the padding characters replaced by space.