Friday, September 18, 2020

Transpose rows to columns using Talend

 


 

Job:

Procedure:

1.       Create a file delimited metadata for the file named as Sample Data.

2.       Drag the metadata created into the workspace and use tFileInputDelimited_1 component.

3.       Now sort the data using tSortRow_1 component as below

4.       Now drag the tPivotToColumnsDelimited component and connect it to the tSortRow_1 Component RowàMain


5.       Double click the tPivotToColumnsDelimited component and mention the operations as shown below to get desired output

6.       This component can convert rows to columns based on the three different conditions.

Pivot Column – In order to convert rows to columns, we need to identify a one column which need to be converted to multiple columns based on Aggregate column. In above case, Subject is the Pivot Column.

Aggregate column – Aggregation column is the column from source data on which aggregation is to be applied with specific function. In above case, Student_Marks is the Aggregate Column.

Aggregation function – which type of aggregation is to be applied on input data. If no aggregation function is applied, then you can select “First”. Aggregation functions available are Sum, Count, Min, Max, First, Last. In above case, First is the Aggregate function.

Group by – You need to provide a group by column name, this is the column based on which pivot columns are created. In above case, Student_Name is the group by Column.



7.       To display the output obtained drag the tFileInputDelimited_2 component and connect to the subjob triggeràOnSubjobOk and edit its schema with the columns name as

8.       Now give the path of the output file in the tFileInputDelimited_2 and connect to tLogRow to display the output

Output:

 

1 comment: