Scenario: Reading data from a positional file - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

The following scenario reads data from a positional file, which contains two schemas. The positional file is shown below:

schema_1 (car_owner):schema_id;car_make;owner;age
schema_2 (car-insurance):schema_id;car_owner;age;car_insurance
1bmw     John      45
1bench   Mike      30
2John      45 yes 
2Mike      50 No      

Dropping the components

  1. Drop one tFileInputMSPositional and two tLogRow from the Palette to the design workspace.

  2. Rename the two tLogRow components as car_owner and car_insurance.

Configuring the components

  1. Double-click the tFileInputMSPositional component to show its Basic settings view and define its properties.

  2. In the File name/Stream field, type in the path to the input file. Also, you can click the [...] button to browse and choose the file.

  3. In the Header Field Position field, enter the start-end position for the schema identifier in the input file, 0-1 in this case as the first character in each row is the schema identifier.

  4. Click the [+] button twice to added two rows in the Records table.

  5. Click the cell under the Schema column to show the [...] button.

    Click the [...] button to show the schema naming box.

  6. Enter the schema name and click OK.

    The schema name appears in the cell and the schema editor opens.

  7. Define the schema car_owner, which has four columns: schema_id, car_make, owner and age.

  8. Repeat the steps to define the schema car_insurance, which has four columns: schema_id, car_owner, age and car_insurance.

  9. Connect tFileInputMSPositional to the car_owner component with the Row > car_owner link, and the car_insurance component with the Row > car_insurance link.

  10. In the Header value column, type in the schema identifier value for the schema, 1 for the schema car_owner and 2 for the schema car_insurance in this case.

  11. In the Pattern column, type in the length of each field in the schema, the number of characters, number, etc in each field, 1,8,10,3 for the schema car_owner and 1,10,3,3 for the schema car_insurance in this case.

  12. In the Skip from header field, type in the number of beginning rows to skip, 2 in this case as the two rows in the beginning just describes the two schemas, instead of the values.

  13. Choose Table (print values in cells of a table) in the Mode area of the components car_owner and car_insurance.

Executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 or click Run on the Run tab to execute the Job.

    The file is read row by row based on the length values defined in the Pattern field and output in two tables with different schemas.