comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » the last line of a large file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: the last line of a large file [message #55326 is a reply to message #55246] Fri, 10 August 2007 14:15 Go to previous messageGo to previous message
little davey is currently offline  little davey
Messages: 5
Registered: June 2007
Junior Member
On Aug 9, 2:49 pm, queiny <quein...@yahoo.com> wrote:
> Hi,
>
> I am processing a large file with data in the same format till the
> last line. In the last line, it states how many records are included
> in this file.
>
> So the structure of my program is:
>
> while not eof(in_unit) do begin
> readf, in_unit, input_line
> if( input_line ne 'last line) then begin
> .....
> else
> ....
> endif
> endwhile
>
> Do I have to use 'if/then' to test whether every input_line is the
> last line of the file? Since there are many data records in the file,
> repeat calls to 'if/then' can be time consuming. But if I don't do the
> test, the program will be halted when it read in the last line.
>
> A Easy way I can think of is to delete the last line, but sometime we
> are not supposed to change the input files.

Would it be faster to use ON_IOERROR? One could process the "normal"
cases of reading the input lines. When there is an IO_ERROR, you trap
it and close the file. Naturally if there is a real IO_ERROR, you'd
have to test for a "real" input error, or the end of the file. But
that would mean IF statements executed only if there were IO_ERRORS.

-- Little Davey --
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL resources
Next Topic: IDL resources on my Web page

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 03:08:13 PDT 2025

Total time taken to generate the page: 0.00632 seconds