Page 1 of 1

Concatenate multiple lines of data into a single line.

Posted: Sat May 28, 2022 6:23 am
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 ^

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

Posted: Tue May 31, 2022 1:55 pm
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.

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

Posted: Sat Jun 04, 2022 9:23 am
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.

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

Posted: Mon Nov 21, 2022 4:05 pm
by ray.wurlod
Transformer stage with the same loop that Paul outlined.