Page 1 of 1

Implementing Transpose functionality in Datastage 8.5

Posted: Fri Dec 13, 2013 9:03 am
by kumarkb
Good Morning Gurus,

Following is my requirement

Source Data
==========
col1|col2|col3|col4
1|A|05-06-2013|15.6
2|B|07-08-2013|26.7
3|C|09-10-2013|37.8
4|D|11-12-2013|48.9


Target Data
=========
col1|1|2|3|4
col2|A|B|C|D
col3|05-06-2013|07-08-2013|09-10-2013|11-12-2013
col4|15.6|26.7|37.8|48.9

I tried below mentioned Unix command (program) to Transpose the data,
(i.e., Rows to Columns & Columns to Rows)

"awk -F "|" '{for (f = 1; f <= NF; f++)a[NR, f] = $f}NF > nf { nf = NF }END {for (f = 1; f <= nf; f++)for (r = 1; r <= NR; r++)printf a[r, f] (r==NR ? RS : FS)}' ABC.txt > ABC_transpose.csv"

where ABC.txt is my source and ABC_transpose.csv is my target set

I am able to get the expected result set in expected format but I am curious to know if this can be achieved directly by using parallel job

-KK

Posted: Wed Dec 18, 2013 8:53 am
by nikhil_bhasin
Try Pivot stage. You need to add 1 column with a constant value and then use pivot enterprise stage. This would not get you the column names though.

Posted: Wed Dec 18, 2013 9:24 am
by chulett
... column names you would have to manually hard-code and add to the flow before pivoting.