Deleting header of Data file In UNIX

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
sribuz
Premium Member
Premium Member
Posts: 19
Joined: Mon Jun 04, 2007 7:26 pm
Location: US

Deleting header of Data file In UNIX

Post by sribuz »

Hi,
I am getting a data file into Unix box and it is generated using COBOL.
The file has Header and footer repeating every page, my objective is to eliminate header and footer and process records between them.

I used sed command to delete Header but the real problem is the previous record is also deleted with header.
When I open the file in vi editor i could see ^L (in blue) between the previous record and header.

I got to know ^L stands for new form.

I need help eliminating header without deleting any records.

Thank you in advance.
Thanks & Regards,
Sri
saikir
Participant
Posts: 92
Joined: Wed Nov 08, 2006 12:25 am
Location: Minneapolis
Contact:

Post by saikir »

Hi,

If you have some kind of record identifier to identify the Header records then you can remove the header records by having a constraint in the Transformer.

Sai
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What "sed" command did you use? If you use a line-oriented command in sed it will not recognize ^L as a line break. Perhaps you could do 2 actions or 2 passes - replace your form feed with a normal line break then remove the headers.
sribuz
Premium Member
Premium Member
Posts: 19
Joined: Mon Jun 04, 2007 7:26 pm
Location: US

Sed command I used

Post by sribuz »

I used

sed -e "/Header Start/,/End Word/d" orginalfile.dat>newfile.dat

This will search for 'headerStart' and delete lines till it reaches 'endword'.
using this command I have deleted the all header instances and saved into newfile.

FYI we put /Header Start/,/End Word/d in double quotes (as in above statement) if the 'Start Word' or 'End Word' have spaces in between.
Thanks & Regards,
Sri
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm no sed expert, but you could put in

Code: Select all

sed -e 's/\o014/\o015/' -e "/Header Start/,/End Word/d"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea:
Ask the COBOL developers to generate a file that lacks these headers and footers.
All they need to do is to comment out some statements.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sribuz
Premium Member
Premium Member
Posts: 19
Joined: Mon Jun 04, 2007 7:26 pm
Location: US

Re: ArndW

Post by sribuz »

ArndW wrote:I'm no sed expert, but you could put in

Code: Select all

sed -e 's/\o014/\o015/' -e "/Header Start/,/End Word/d"
...

Tried the sed command given by you, still deleting the record before the header.
Thanks & Regards,
Sri
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I was guessing at the sed command. Please the man pages on sed to see what mistake I must have done with the first part; most likely I chose the wrong octal code for the FF character.
Post Reply