header and tailer sequential file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
yogadeep
Participant
Posts: 1
Joined: Fri Mar 09, 2007 8:43 am

header and tailer sequential file

Post by yogadeep »

hey how can i remove headers and tails from a sequential file
i have three lines as headers and 4 lines are tails.........
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi and Welcome Aboard :D !!!

"First line is column name" option available in Format tab will avoid the Header to be read. To avoid you may use Filter option and tail command to skip the last row.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Does your UNIX support +3 option for the head command and the +4 option for the tail command? If so, you have a very easy filter you could use to get the detail rows only.

"First line is column names" will ignore only one row, not three.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

i have three lines as headers and 4 lines are tails.........
Yeah, didn't observed this properly.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... or even as a filter command (without the filename) in a Sequential File stage, which will then read the stdout of sed
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

There are a bunch of sed one liners that can be found on google. Search for 'em.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If "head +" option didn't work with the first option suggested by Ray, then the following can be used.

Code: Select all

head -$(expr $(wc -l filename | awk '{ print $1 }') \- 4) filename | tail +4
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

use:

Code: Select all

sed '1,3 d' f | sed -e :a -e '$d;N;2,4ba' -e 'P;D'
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
Post Reply