Page 1 of 1

Sequential Stage

Posted: Tue Dec 02, 2003 6:59 pm
by mimran
I've a file consisting of records with different format.

The first record is of one format.
The following couple of records belong to one format
The last record is of another format

I would like to ouput these three different types of records in 3 different files.

Can I achieve this using sequential file stage?? If yes, then how??

What stage to use if not possible with sequential file stage??

Thanks in advance.

Posted: Tue Dec 02, 2003 7:13 pm
by vmcburney
If your file always has the same mixed format you can split it up using simple Unix commands.

This command will give you the first line:
head -1 filename > newfilename

This one gives you the last line:
tail -1 filename > newfilename

This one gives you the 2nd and 3rd lines:
head-3 filename | tail -2 > newfilename

You can run these three commands from a DataStage routine or from a DSExecute stage in a sequence job.

Sequential Stage

Posted: Wed Dec 03, 2003 8:43 am
by bigpoppa
Also,

sed '1d;$d' filename >> outfilename

will put all the records in filename except the first and last into outfilename.

-BP