Multiple rows to single row comma separated values

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

priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

I don't really know the details but here you can trim the output using below code:

Code: Select all

Trim(<value>,',','B')
However in case the record delimiter is set a ',' it should work.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

Sainath.Srinivasan wrote:Isn't that what you asked for ? Trim the trailing comma.
When I am trying to read that file in a separate job where I can trim that trailing comma, i am able to trim the last comma and getting the desired output but the job throws warning like Missing Record delimiter '''', saw EOF instead, and moreover I wanted to achieve this in a single job instead of 2 jobs.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So put the "trim the trailing comma" logic into the first job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

How do you intend to use this file in the downstream process ?

In the place you read the file, mention record delimiter as 'none' and work with the plan that there is an extra comma. No need to worry about it.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ray.wurlod wrote:So put the "trim the trailing comma" logic into the first job. ...
I am getting the comma separeted values when I am collecting the data in the file in the first job, hence I cannot trim the trailing comma there.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

Sainath.Srinivasan wrote:How do you intend to use this file in the downstream process ?

In the place you read the file, mention record delimiter as 'none' and work with the plan that there is an extra comma. No need to worry about it.
I have tried all the different options while reading the file in the next job, but it always throws the warning. I am getting the desired output put the warning is bugging me.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Did you try 'record delimiter = none' ?
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

Sainath.Srinivasan wrote:Did you try 'record delimiter = none' ?
Tried out all the options but cannot get rid of the warning.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Can you post the warning message?
You are the creator of your destiny - Swami Vivekananda
victor236
Participant
Posts: 8
Joined: Thu Aug 12, 2010 10:37 am

Post by victor236 »

pravin1581 wrote:
Sainath.Srinivasan wrote:Read the source and write an output with record delimiter as comma
Thanks Sai. I tried this , the output is coming as 1,2,3,4,
Hi Pravin,

I am looking at this thread which seems to be important and may be useful any time.

Can you tell me how did you try this, did you try this with the pivot stage?
I am using Server job on windows server where I could not get the result what you posted. Just seeking some help to try this.
Victor
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

similar requirement

Post by UAUITSBI »

pravin1581 wrote:
arunkumarmm wrote:Or even in a simpler way, create a stage variable like this:

sv1 = sv1 : ',' : InputColumn

and map it to the target column derivation.

The last output row will have all the values...
This doesn't works . The output is coming as 0,0,0,0,
Hi,
Can you tell me how did you define your Stage Variable exactly?I am getting the same result with 0's in output column
reachmexyz
Premium Member
Premium Member
Posts: 296
Joined: Sun Nov 16, 2008 7:41 pm

Re: Multiple rows to single row comma separated values

Post by reachmexyz »

Try unix commad
paster -s -d, source_file > Target_file
Phani01
Participant
Posts: 7
Joined: Mon Jun 22, 2009 8:41 am

Post by Phani01 »

So Pravin, What was the logic you implemented.

Could you please let us know.
Thanks,
Phani Kumar
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

Post by marpadga18 »

pravin1581 wrote:
Sainath.Srinivasan wrote:Read the source and write an output with record delimiter as comma
Thanks Sai. I tried this , the output is coming as 1,2,3,4,
Hi could you tell me how you did you get it? I have same thing to do.
I did with stage variable logic but it is giving
0
0
0
0
could you corrcet me where I am doing worng?
Thanks M
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

Post by marpadga18 »

arunkumarmm wrote:
pravin1581 wrote:This doesn't works . The output is coming as 0,0,0,0,
This should work. May be try defining the initial value of your stage variable to '' {Empty}

If you are mapping the column properly, how come this doesnt work? No complex thing involved in this. You are just appending your column to the stage variable. I have did this before and it worked. All you need to do is to check if everything is setup properly.
Hi Arun I did this but I am also getting 0,0,0,0,0, data is not comming. I tried your data as example could you tell me were I am doing wrong?

sv1 = sv1 : ',' : Inputcolumn
Post Reply