Breaking a single column to multiple columns

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
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Breaking a single column to multiple columns

Post by Rakesh311 »

HI

I had a requirement
my source file(.csv format) is like

c1 c2 c3
a 1 22
b 1 22 21
c 2 12 21 22
d 4 12 21 22 33


I need output like

c1 c2 c3
a 1 22
b 1 22
b 1 21
c 2 12
c 2 21
c 2 22
d 4 12
d 4 21
d 4 22
d 4 33


like this

Thanks you for your help in advance
rAKESH
iHijazi
Participant
Posts: 45
Joined: Sun Oct 24, 2010 12:05 am

Post by iHijazi »

Transformer, Stage Variables and Partitioning with sorting are your best friend in this case.

Put some logic, you can treat the whole as a single column or segment them to different columns (but that's dependent on the type of separator you have ,for instance it could be space).

In the transformer use the variables and store in them after partition and sorting. Do the same for output (sorting), and use remove duplicates stage if needed afterward.

Cheers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Create column definitions for C4, C5 and C6 and use 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.
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Re: Breaking a single column to multiple columns

Post by Rakesh311 »

hi all
but there is no limit for the count of values in cl3.It can be any 'n' numbers separated by " "(space).

Thanks
rAKESH
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

None of that information was in your original question, which advised comma delimited. However, you can re-parse your data into as many columns as required - it's still a pivot that you want 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