What stage can acomplish splitting variable length recrods

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
reachsam11
Participant
Posts: 26
Joined: Wed Mar 17, 2010 11:05 am

What stage can acomplish splitting variable length recrods

Post 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
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post 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
You are the creator of your destiny - Swami Vivekananda
agpt
Participant
Posts: 151
Joined: Sun May 16, 2010 12:53 am

Post by agpt »

Did you try Pivot?
reachsam11
Participant
Posts: 26
Joined: Wed Mar 17, 2010 11:05 am

Post by reachsam11 »

Unix script works fine for this requirement. Thanks for the quick repsonse! :)
ReachSam
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Then mark this topic as Resolved :)
You are the creator of your destiny - Swami Vivekananda
Ananda
Participant
Posts: 29
Joined: Mon Sep 20, 2004 12:05 am

Post by Ananda »

Datastage solution :

Read the record as a single field, use the Field() function to split up the columns.
If you don't fail now and again, it's a sign you're playing it safe.
Post Reply