Implementing Transpose functionality in Datastage 8.5

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kumarkb
Premium Member
Premium Member
Posts: 10
Joined: Fri Oct 09, 2009 2:08 am
Location: india

Implementing Transpose functionality in Datastage 8.5

Post 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
Thanks & Regards
KB
nikhil_bhasin
Participant
Posts: 50
Joined: Tue Jan 19, 2010 4:14 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... column names you would have to manually hard-code and add to the flow before pivoting.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply