ETL: Combining data and header

Am a beginner in Knime.

I want to combine Adult_income data set (41 columns) in file-A and column header information in file-B to a single file. file-B is in columnar format - that is 1 column multiple (41) rows.

What I have done is 

1. Read file-B (Column headers file) using CSV Reader node

2. Transpose file-B to get 1 row, 41 columns file using transpose node. But the output has column headers as Row0, Row1.. Row40 etc.

3. Use extract column header to convert and take output from port1 to get a row of data where column names are Col0, Col1,, Col40

4. Read file-A (data file) using CSV reader node. 

5. Use Concatenate node to combine output of step 3 (Port 1, not Port 0) and step 4. (This steps add the data header names as the first row from step-3, followed by rows from step4.

6. Use CSV Writer node to  write output of step 5 as file-C (Data and header combined)

7 Subsequently read file-C using CSV reader, enabling 'Has Row Header'

Is there a better way to achieve this inKnime?

 

 

Hi,

Did you consider using the Insert Column Header node? You just need to add the lookup values to the table from your file-B matching the original column names in the table from your File-A. All the header replacements will be taken care by the node itself.

Maybe post a sample of your data so you can get a more specific help.

Cheers,
Marco.

Thanks Marco!

FileA (actual dataset - census-income) does not contain a header and hence in Knime, it shows as Col0, Col1, Col2 etc. for the column names.

RowID    [I]Col0   [S]Col1      [I]Col2 .....

Row0      39          Private           22

Row1      18          Self-empl      12

etc.

File B is a single column Table with new column names.In Knime, different rows representing the new column names are shown against Row0, Row1, Row2 etc.

RowID    [S]Col0

Row0     Age

Row1     Class of Work

Row3     Industry code

etc.

If I transpose, column names become Row0, Row1 etc.

RowID       [S]Row0  [S]Row1              [S]Row2 etc.       

Col0           Age          Clas of Work       Industry code

If there is a way the share the workflow to you, I can do so.