How do I split a input row into multiple output rows

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Champa
Participant
Posts: 88
Joined: Wed Dec 14, 2005 1:44 pm

How do I split a input row into multiple output rows

Post by Champa »

Hey guys,

The input file is as below

1|711,729a,726|h711_729A_726_ppsp|H323

1|711,729a,726|s711_729A_726_ppsp|SIP

2|729ab,726,711|h729AB_726_711_ppsp|H323

2|729ab,726,711| s729AB_726_711_ppsp|SIP

The output file should be as below.

Codec_Descriptor_ID=1|Codec_Descriptor_Value=711

Codec_Descriptor_ID=2|Codec_Descriptor_Value=726

Codec_Descriptor_ID=3|Codec_Descriptor_Value=729a

Codec_Descriptor_ID=4|Codec_Descriptor_Value=729ab

Any suggestions???

Thx
Champa
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: How do I split a input row into multiple output rows

Post by gateleys »

What's your input stage? Flat-file? What about your output stage?

gateleys
Champa
Participant
Posts: 88
Joined: Wed Dec 14, 2005 1:44 pm

Post by Champa »

Both sequential files
Champa
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

hi champa,
ok if i understood your question correctly then do this,
specify four columns in your source seq. file
col A , col B, col C and col D
specify the quote character as 000
have a link going from this seq. file stage into a transformer.
pull col B into a stage variabe and give the derivation as

Code: Select all

Field(In.col B,",",1):char(010):Field(In.col B,",",2):char(010):Field(In.col B,",",3)
in the above code, char(010) is the value for a line terminator in unix.
have this link going into a seq. file stage.
in this seq file stage, specify both the delimiter and quote character as 000.
you will see that your output will have the following values

Code: Select all

711
729a
726
711
729a
726
729ab
726
711
729ab
726
711

now you have all those values, just repeating themselves. Now you only want discrete of those values.
you can pass that through a hash file, into a sec. transformer, where you can attach the column Codec_Descriptor_ID, use it as an identity column and finally into the target seq. file
so if you did all that correctly, your target file should have the require output that you desire.
i hope it helps
cheers
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

forgot to mention one point, make sure the delimiter you specify in your source seq. file stage is " | " and not a " , ".
:)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Champa

Explain the logic of how do you get this result. The logic is not mentioned clearly in your question
The output file should be as below.

Codec_Descriptor_ID=1|Codec_Descriptor_Value=711

Codec_Descriptor_ID=2|Codec_Descriptor_Value=726

Codec_Descriptor_ID=3|Codec_Descriptor_Value=729a

Codec_Descriptor_ID=4|Codec_Descriptor_Value=729ab
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

I agree. It is a vague and ambigous presentation of your problem. It would help if you could verbalize a little more and also about your file-formats.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Post Reply