Concatenate multiple lines of data into a single line.

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
tbtcust
Premium Member
Premium Member
Posts: 230
Joined: Tue Mar 04, 2008 9:07 am

Concatenate multiple lines of data into a single line.

Post by tbtcust »

Hello all. I have a requirement to concatenate multiple lines of data into a single line. See example below. I have tried solutions in a transformer stage variables with no success. Any help/advise would be greatly appreciated.

Example
Input:
name age address
John|43|1015 main street
Queens
New York 10035 ^
Jackie|51|1015 main street Queens New York 10035 ^
James|50|10 Court LN
Raleigh
North Carolina 12045 ^

Output:
name age address
John|43|1015 main street Queens New York 10035 ^
Jackie|51|1015 main street Queens New York 10035 ^
James|50|10 Court LN Raleigh North Carolina 12045 ^
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Re: Concatenate multiple lines of data into a single line.

Post by PaulVL »

Shell script with a loop.

start of loop:
$line1=read the line from input;
$line2=read the line from input;
$line3=read the line from input;
echo it to the output "$line1 $line2 $line3";
end of loop

if condition the loop to beak out once you reach the end of file.
tbtcust
Premium Member
Premium Member
Posts: 230
Joined: Tue Mar 04, 2008 9:07 am

Re: Concatenate multiple lines of data into a single line.

Post by tbtcust »

Thank you so much PaulVL.

I'm hoping for a DataStage solution, as the the resources may not have sufficient skills to support a script solution.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Concatenate multiple lines of data into a single line.

Post by ray.wurlod »

Transformer stage with the same loop that Paul outlined.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply