convert single column records into a string

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
har
Participant
Posts: 118
Joined: Tue Feb 17, 2004 6:23 pm
Location: cincinnati
Contact:

convert single column records into a string

Post by har »

Hi folks,
Input is like this,
10
15
256
765
Im trying to get Output in this format:
10,15,256,765
i need to insert comma between each record like above format.

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

Post by ray.wurlod »

Process this in UNIX, using a utility like sed to change all the line terminator characters to commas.
This leaves a blank final field, you can further process the result if this will be a problem.
It can be done in DataStage, but is easier and faster using the sed utility.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
har
Participant
Posts: 118
Joined: Tue Feb 17, 2004 6:23 pm
Location: cincinnati
Contact:

Post by har »

Thanks Ray..
im just curious how can i implement this in DataStage
Thanks
har
Har
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

sed is Stream Editor which can be used in unix.

ex: cat filename | sed s/old_text/new_text/g

The above will change all the old_text to new_text. You can redirect to a output file to captured the replaced text.

Name this as a shell script and run this like the other unix command.

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

Post by ray.wurlod »

The easiest way to do this in DataStage is as follows.
  • In a Transformer stage construct a stage variable, which accumulates the comma-delimited string.
    Run the output through a subsequent Aggregator stage, using Last as the aggregate function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
changming
Participant
Posts: 68
Joined: Wed Oct 13, 2004 3:35 am

use row merger

Post by changming »

you can use row merger read the source file into a multi column file then use row merger stage read this file and merg all column into one cloumn. It is easy to use.
Post Reply