Page 1 of 1

merging multiple line as one record -- Seq data file

Posted: Thu Jul 08, 2004 2:21 pm
by murur
I am getting an input data file in the following format

{1111111111111111
:22222
:3333333
:44444444
:55
:66
-}
{
...................
-}

Need to transform into (merge multiple line into ONE record.. number of
lines has to be merged is always constant 7 , first line { and 7th line -}
{1111111111111111:22222:3333333:44444444:55:66-}
{ ...................-}


How do I implement this, Any idea...?

Thank you,
Muru

Posted: Thu Jul 08, 2004 2:26 pm
by kcbland
Read the data from the file as a single column. Use stage variables to queue data and output on change of group --> the "}" character. Since your last row should be that } character you shouldn't have the issue of the last group not being output.

Posted: Thu Jul 08, 2004 6:16 pm
by rasi
Hi Muru

As Ken said you can do that or you can use the mod function(mod(@INROWNUM,7) to split the records.

Another way to do is create 7 different hash file and merge is one job. While creating the hash file you need to generate the key either by using the stage variable or use the mod function. This is just an another way of doing. But the first mentioned one is the most efficient way of doing.

Regards
Rasi

Posted: Fri Jul 09, 2004 9:41 am
by longma98
You can try to preprocess it if it is a unix flat file using sed.

Here is one I stole and modified. Save it in a file and do:

sed -f mySedFile input.dat > output.dat

Basicly, it searches and loops for lines that are not ended with "}" + possible trailing spaces, and removes the "\n" characater.

======
:loop
/} *$/ !{
N
s/\n//
b loop
}
======