Page 1 of 1

extract header and footer info from fixed width file

Posted: Tue May 05, 2009 6:43 am
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

Posted: Tue May 05, 2009 7:13 am
by Sainath.Srinivasan
How big is your input file ?

Posted: Tue May 05, 2009 7:36 am
by snt_ds
six extracts are there and in that 4 are like 100000 records.
2 of them are very big like 1300000

Posted: Tue May 05, 2009 7:39 am
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?

Posted: Tue May 05, 2009 8:34 am
by snt_ds
I need first line and last line for each file.

Posted: Tue May 05, 2009 8:48 am
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.

Posted: Tue May 05, 2009 8:49 am
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.

Posted: Tue May 05, 2009 9:00 am
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?

Posted: Tue May 05, 2009 9:22 am
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?

Posted: Wed May 06, 2009 8:28 am
by snt_ds
Hi ShaneMuir ,

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

Posted: Wed May 06, 2009 11:15 am
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.