Page 1 of 1

Reading A File with variable record length

Posted: Mon Aug 22, 2005 11:12 am
by bapajju
Hello,

We are trying to read a file that has records with variable lengths.For example, one record has 5 Fields, the second record has 7 fields, the third record has 4 fields.

What would be the simplest way to read such a file. Please let me know.

thanks
Amitav

Posted: Mon Aug 22, 2005 11:15 am
by ArndW
When reading a sequential file you can specify attributes for what to do when a column is missing or null. I would suggest you define the maximum number of columns but for those that might be missing in certain rows declare them to be empty when they aren't defined in the source.

Posted: Mon Aug 22, 2005 11:29 am
by bapajju
Thanks ArndW. Thanks for the quick response. I will try it out.

Posted: Mon Aug 22, 2005 11:43 am
by Sainath.Srinivasan
You also need to analyze the reason and business logic for this variation.

Posted: Mon Aug 22, 2005 4:16 pm
by chitra
If you have a preprocessing script like Shell/perl script, You can also convert the file as a delimited file and read it from the sequential file stage.