Page 1 of 1

skip the first and last record of a file

PostPosted: Wed Jul 28, 2010 3:07 pm
by Kal El
I have an input file with 1st and last record containing a date field.I want to skip these records.Kindly let me know how to do so.

These records contain date values.

Re: skip the first and last record of a file

PostPosted: Wed Jul 28, 2010 7:48 pm
by NicC
Question is...what have you tried so far? I would try reading the first 2 records, save the second record, read the next record, if not end of file then process saved record, save third record, read next record, if not end of file.....when end of file do not process last record read.

Or run through some utility e.g a sort and drop firat and last records that way and then process the resultant file. Which way you go is up to you/your shop standards etc.

Re: skip the first and last record of a file

PostPosted: Thu Jul 29, 2010 1:09 am
by dick scherrer
Hello,

If the file has 400,000,000 records, i'd suggest doing it with the code rather than a separate utility step to copy the file minus the 2 unwanted records. . .

Re: skip the first and last record of a file

PostPosted: Sun Aug 08, 2010 5:08 pm
by Kal El
At first I thought of using an inspect clause on the first record...as it has a different value(date) than the rest of the data in the file...so the moment i encounter date i shall skip it go to the next record..and resume processing....However if the second record also happens to be a date due to some error etc. then my code will skip it as well.....

Re: skip the first and last record of a file

PostPosted: Sun Aug 08, 2010 8:15 pm
by NicC
Why look at the first record at all? Ypu know it is ithe first record because it is your first read and your count of records read should be 1. Obviously you cannot do the same wih the last record but if it is a trailer record then it would have identifier that you could look for and when you get it just ignore the record, set end-of-file manually and continue to end of program.

Re: skip the first and last record of a file

PostPosted: Thu Aug 12, 2010 1:47 pm
by Vikrant Survase
yaa just read 2 records at a time and use count ,frist time skip the frist record and for last time skip the second record.
hope this will help.