In this Job, you use the tUnpivotRow and the
tMap component to convert columns to rows.
Procedure
Create a Job named UnPivotColumnsToRows, composed of the
following components linked by three main rows:
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.
Double-click tFileInputDelimited to open its
Component view.
Fill the File name/Stream field with path of the .txt
file you created for example, "D:/file/in.txt".
Change the Header field to
1.
Click the ellipsis button (...) to edit the schema of the component.
Delete the columns pivot_key and pivot_value.
Add a column named Id of
Integer type and a three columns
Name, Sex and
Surgrey of String
type.
Double-click tUnpivotRow to add an input column named
Id in the Row keys box.
Edit the tUnpivotRow schema and add an
output column named Id of Integer
type as below.
Information noteNote: Both output columns Pivot_key and
Pivot_value are pre-defined columns and read only
tUnpivotRow component.
Double-click the tMap component to open its schema and drag
the columns id, pivot_key and
pivot_value from the Row2 table to
the out1 table.
Respectively change the pivot_key and
pivot_value name of the out1
table to Question and
Answer.
Information noteNote: Because both columns (Pivot_key and
Pivot_value) are read only in the
tUnpivotRow component, you must change the column
names in tMap to map to the target schema.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!