Split a record into multiple records

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
rajendharreddy
Participant
Posts: 46
Joined: Tue Aug 21, 2007 5:39 am
Location: Bangalore, India

Split a record into multiple records

Post by rajendharreddy »

Hi,

I have a requirement as mentioned below. I need to split one record into multiple columns as shown below.

Input Record
---------------
Col1
a,b,c,d
d,e
f,g,h

Col1|Col2|Col3|Col4
a|b|c|d
d|e
f|g|h

Could anyone help me out on the above.

Thanks in advance.

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

Post by ray.wurlod »

Concatenation in Transformer stage.

Column Export 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.
soumya5891
Participant
Posts: 152
Joined: Mon Mar 07, 2011 6:16 am

Post by soumya5891 »

You can use a transformer stage variable also to split the records
Soumya
senthil_k
Participant
Posts: 3
Joined: Mon Mar 31, 2008 2:31 am

Post by senthil_k »

Use Field Function in transformer
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

ray.wurlod wrote:Concatenation in Transformer stage.

Column Export stage. ...

My idea to get the required output is as follows

1)Input is read as once column as id

2)count the no of delimiters in each record and Concatenatinating required delimiters for example for second record input is -d,e so i am adding d,e,, since the no of fields in the output is four.


3)Then using column import stage to parse the one column into four columns


Just want to know how to get the required o/p with Concatenation and Column Export stage.Please correct me if i am wrong?
Last edited by vamsi.4a6 on Mon May 21, 2012 1:45 am, edited 1 time in total.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

approch is dependant on what you want. Are you going to write it directly to a file then you just need to replace the delimiters from comma to pipe and add a header for column names using convert().

if you need to split the incoming column in four columns then you can read it in single column and feed it to column export stage.

It can also be done in a transformer to split the columns using field function and then you may need to do null handling for missing values if performing the task in stage variables.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

@priyadarshikunal

if you need to split the incoming column in four columns then you can read it in single column and feed it to column export stage.


Doubt:for splitting the column one from i/p to four columns we will use column import stage not column export stage.please correct me if i am wrong?
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

vamsi.4a6 wrote:@priyadarshikunal

if you need to split the incoming column in four columns then you can read it in single column and feed it to column export stage.


Doubt:for splitting the column one from i/p to four columns we will use column import stage not column export stage.please correct me if i am wrong?
Could anybody please clarify on the above point for column import stage?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What above point, exactly? If you are unsure which 'direction' the Column Import or Column Export stages go, why not simply check the documentation? It is stated quite clearly there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply