Page 1 of 1

What stage can acomplish splitting variable length recrods

Posted: Tue Jun 08, 2010 11:30 am
by reachsam11
Hi my requirement is to split a varaible lenght record into fixed lenght records. What stage can accomplish this?

Input
Key,Col1,Col2,Col3,......... (can go up to 700 variable columns)
123,100001,100002,100003,100004
223,200001,200002,200003
323,300001,300002,300003,300004,300005



Desired output
Key,Col
123,100001
123,100002
123,100003
123,100004
223,200001
223,200002
223,200003
323,300001
323,300002
323,300003
323,300004
323,300005

Posted: Tue Jun 08, 2010 11:44 am
by anbu
Unix solution

Code: Select all

$ cat file
123,100001,100002,100003,100004
223,200001,200002,200003
323,300001,300002,300003,300004,300005
$ awk -F"," ' { for(i=2;i<=NF;++i){print $1","$i}} ' file
123,100001
123,100002
123,100003
123,100004
223,200001
223,200002
223,200003
323,300001
323,300002
323,300003
323,300004
323,300005

Posted: Tue Jun 08, 2010 12:11 pm
by agpt
Did you try Pivot?

Posted: Tue Jun 08, 2010 12:57 pm
by reachsam11
Unix script works fine for this requirement. Thanks for the quick repsonse! :)

Posted: Tue Jun 08, 2010 1:15 pm
by anbu
Then mark this topic as Resolved :)

Posted: Wed Jun 09, 2010 4:00 pm
by Ananda
Datastage solution :

Read the record as a single field, use the Field() function to split up the columns.