Page 1 of 1

Breaking a single column to multiple columns

Posted: Tue Feb 01, 2011 10:59 pm
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

Posted: Tue Feb 01, 2011 11:55 pm
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

Posted: Tue Feb 01, 2011 11:58 pm
by ray.wurlod
Create column definitions for C4, C5 and C6 and use a Pivot stage.

Re: Breaking a single column to multiple columns

Posted: Wed Feb 02, 2011 12:06 am
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

Posted: Wed Feb 02, 2011 3:28 am
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.