Food for thought - Pivoting

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
Django
Premium Member
Premium Member
Posts: 20
Joined: Fri Apr 18, 2008 12:16 am

Food for thought - Pivoting

Post by Django »

Hello Ds Guruz

I need help to pivot a seq. file with 2 columns to another seq. file with 2 columns.

Code: Select all


Input Sequential File 
------------------
Name    Score
------------------
Ramyt   1,2,3
Renai    5,6,7,8,9,10,345,122,456
Scott     345,67,23,1,8,4,45,89,23,78,90,100,60,23,12
Brian     23,45
etc

The length of the score is varying comman seperated list

I want the output as follows

------------------
Name    Score
------------------
Ramyt  1
Ramyt  2
Ramyt  3
Renai   5
Renai   6
Renai   7  
and so on

How to achieve this ?

Any idea ?
Django
If a simple dsx project requires such intelligence how much more is required to create this Cosmic System. Who dares to say there is no intelligence behind this creation i.e. no GOD .....
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is there a comma between the name and the list of scores? If so read the file as comma delimited and run it through a Pivot stage. If not, convert it to this format (maybe with a Transformer stage), re-parse it (maybe with a Column Input stage) and then run it through a Pivot stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Django
Premium Member
Premium Member
Posts: 20
Joined: Fri Apr 18, 2008 12:16 am

Varying Length

Post by Django »

Ray

I understand your point of pivoting. Assuming that we make the comma seperated list into columns. But the issue is the the number of input columns are varying. It can be 1 upto say 200 or more. I dont want to map into 200 columns..

:cry:
Django
If a simple dsx project requires such intelligence how much more is required to create this Cosmic System. Who dares to say there is no intelligence behind this creation i.e. no GOD .....
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not? You're expecting to get 200 rows in this case. The columns will only be visible within DataStage, nowhere else.

If you were prepared to use a server job, you could use the multi-value handling and dynamic normalization capability of a hashed file to solve this for an arbitrary number of columns per row with no programming at all but, since you posted in the parallel forum, I conclude that this is not what you wish to do.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply