Creating an example file to convert columns to rows
This procedure explains how to convert columns to rows.
Create a .txt file example with the following data:
Id;Name;Sex;Surgery
1;Shong;M;Y
2;Ross;M;Y
3;Elise;F;N
The columns will become rows as follows:
Id;Question;Answer
1;Name;Shong
1;Sex;M
1;Surgrey;Y
2;Name;Ross
2;Sex;M
2;Surgrey;Y
3;Name;Elise
3;Sex;F
3;Surgrey;N
To accomplish this task, install the custom component called tUnpivotRow available on the Talend Exchange. For more information about installing a custom component, see on Talend Help Center (https://help.talend.com).
Converting columns to rows
In this Job, you will use the tUnpivotRow and the tMap component to convert columns to rows.
This Job will use the following components:
- a tFileInputDelimited component to read data from in.txt file,
- a tUnpivotRow component to convert columns of the person table to rows,
- a tMap to generate an output table,
- and a tLogRow component to print output data on the console.
Procedure
Executing the Job
Procedure
Execute the Job. The following results are output to the console: