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

Home » Public Forums » archive » Re: 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 #55238 is a reply to message #55237] Fri, 10 August 2007 05:34 Go to previous messageGo to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Aug 9, 5:22 pm, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
> Jean H. wrote:
>> Hi,
>
>> If you are sure it is the last line that you want to omit, you could do
>> something like:
>
>> nbOfLines = FILE_LINES(YourFileName)
>
>> for i = 0, nbOfLines - 2 do begin
>> readf, in_unit, input_line
>> endfor
>
> Or, if each record is the same format and consists only of numbers (no A-Z characters),
> you could probably get rid of the above loop too. E.g. say you have 10 columns of numbers
> per record (line)
>
> n_Records = FILE_LINES(YourFileName) - 1L
> ...open the file....
> All_the_Useful_Data = FLTARR(10,n_Records)
> readf, in_unit, All_the_Useful_Data
>
> ?
>
> I think that should work (or something like it).
>
> Of course, if you have records split over multiple lines, then it gets hairier.
>
>
>
>
>
>>> 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.
>
> You should also tell the people who wrote the code that creates the files that the number
> of records information is more useful if they stick it at the beginning of the file. :o)
>
> cheers,
>
> paulv

lol! Really! What in the world is the point of putting the number of
lines at the end of the file? That's got to be about the silliest
thing I've ever heard of. By the time you've actually read to the end
of the file, you already know how many lines there are!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Transforming a nonlinear equation
Next Topic: Removing bad data from an array

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

Current Time: Fri Oct 10 17:45:42 PDT 2025

Total time taken to generate the page: 1.83958 seconds