This scenario describes a three-component Job that uses Java code through a tJavaRow component to display the content of an input file and pass it to the output component. As all the components in this Job support the dynamic schema feature, we can leverage this feature to save the time of configuring each column of the schema.
Drop tFileInputDelimited, tJavaRow, and tFileOutputDelimited from the Palette onto the design workspace, and label them according to their roles in the Job.
Connect the components in a series using Row > Main links.
Double-click the tFileInputDelimited component, which is labeled Source, to display 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.
In the File name/Stream field, type in the path to the input file in double quotation marks, or browse to the path by clicking the [...] button.
In the Header field, type in 1 to define the first line of the file as the header.
Click the [...] button next to Edit schema to open the [Schema] dialog box.
Click the [+] button to add a column, give a name to the column, dyna in this example, and select Dynamic from the Type list. This dynamic column will retrieve the three columns, FirstName, LastName and Address, of the input file.
Click OK to validate the setting and close the dialog box.
Double-click the tFileOutputDelimited component, which is labeled Target, to display its Basic settings view.
Define the output file path in the File Name field.
Select the Include Header check box to include the header in the output file. Leave all the other settings are they are.
Double-click tJavaRow to display its Basic settings view and define the components properties.
Click Sync columns to make sure that the schema is correctly retrieved from the preceding component.
In the Code field, enter the following code to display the content of the input file and pass the data to the next component based on the defined dynamic schema column:
System.out.println(input_row.dyna); output_row.dyna = input_row.dyna;
In the Code field, input_row and output_row correspond to the links to and from tJavaRow.