Page 1 of 1

convert single column records into a string

Posted: Wed Oct 27, 2004 3:49 pm
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

Posted: Wed Oct 27, 2004 4:01 pm
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.

Posted: Wed Oct 27, 2004 4:30 pm
by har
Thanks Ray..
im just curious how can i implement this in DataStage
Thanks
har

Posted: Wed Oct 27, 2004 6:35 pm
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

Posted: Wed Oct 27, 2004 8:47 pm
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.

use row merger

Posted: Thu Oct 28, 2004 3:38 am
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.