Page 1 of 1

Removing Header/Trailer from Seq File

Posted: Wed Oct 03, 2007 10:51 pm
by Meem4m
Hi All,
Can anyone advice me how to remove header and trailer from the Sequential file. The thing is, the source file has two header and two trailer. How to remove those two headers and trailers in Datastage???

Thanks in Advance,
Meem

Posted: Wed Oct 03, 2007 11:24 pm
by ArndW
DataStage jobs don't "read ahead", so they wouldn't know that they have reached a trailer record unless the format were different. I recommend that you use the head and tail commands, which are available to you as you have PX under windows installed.

Posted: Thu Oct 04, 2007 2:28 am
by bkumar103
You can achieve this through the sed.
Write a shell script. Run the shell script as the before job subroutine. The script may be like this

sed '1,1d'< inseqfile > outseqfile -- This can remove the first line from a file
sed '$d' < inseqfile > outseqfile -- This is to remove the last line from the file..

You can arrange the above script to achieve the same what you want.

You can try with Head and Tail stage also.

Posted: Thu Oct 04, 2007 2:59 am
by JoshGeorge
If you have MKS Toolkit installed (Which Ships and installs with version 7.5x2) you can try the below described:

To remove header (2) and footer (2) from your file try this command in your filter option of sequential file satge:

Code: Select all

 
sed 'N;$!P;$!D;$d' -e '1d' -e '2d'

Posted: Thu Oct 04, 2007 6:42 am
by chulett
Won't PX do this 'automagically' because (typically) the metadata for the header/trailer records are different and thus they... reject? :?

Posted: Thu Oct 04, 2007 8:28 pm
by ArndW
Craig - yep, that is the way to do it if the formats of the header/trailer are different and you don't need the data in those rows. The header row is usually column names and will have the same number of column separators as the data, but if you have non-string columns then the text column names will trigger the header row(s) to be rejected.

Posted: Thu Oct 04, 2007 9:25 pm
by ray.wurlod
And one can always re-parse the raw string using Column Import stage. :idea:

Posted: Thu Oct 04, 2007 9:27 pm
by ArndW
Ray - are you sure? I tried to convert that raw type into something useable and failed - I'll look into the column import stage now.