extract header and footer info from fixed width file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

extract header and footer info from fixed width file

Post by snt_ds »

Hi,

My requirement is:

Source: Fixed width file
Target:Fixed width file

Source file contains header and footer, i need to store that info into a table(staging), and include them while loading into target fixed width file.

Could anybody give me an idea how to proceed with this requirement?

Thanks in Advance,
snt_ds
snt_ds
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

How big is your input file ?
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

six extracts are there and in that 4 are like 100000 records.
2 of them are very big like 1300000
snt_ds
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Do your input files have any values to identify headers and trailers or do you just want to get the first and last line of each file?
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

I need first line and last line for each file.
snt_ds
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Well personally I would use a unix script to get the header and trailer records from the input files. (You could store them in a file or load them to a table).

I would then process the incoming files using a file pattern and a column name field and use an external target stage to generate variable file names.

Once you have finished processing you would write another unix script to append the header and trailer records back to their respective files.
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Hi ,

Read the entire file in a varchar column and mention constraints in transformer directing header into one link , trailer into another link and rest of the data into 3rd link.
Nag
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

nagarjuna wrote:Hi ,

Read the entire file in a varchar column and mention constraints in transformer directing header into one link , trailer into another link and rest of the data into 3rd link.
How would you identify the header record and the trailer record?
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Oh sorry ..Here i assumed that there are identifiers to identify the header and trailer records .
ShaneMuir wrote:
nagarjuna wrote:Hi ,

Read the entire file in a varchar column and mention constraints in transformer directing header into one link , trailer into another link and rest of the data into 3rd link.
How would you identify the header record and the trailer record?
Nag
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

Hi ShaneMuir ,

Could you tell me in more detail or If possible can you provide me the unix commands pls.
snt_ds
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

head filename
tail filename
snt_ds wrote:Hi ShaneMuir ,

Could you tell me in more detail or If possible can you provide me the unix commands pls.
Post Reply