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 #55242 is a reply to message #55238] Thu, 09 August 2007 14:22 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
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
[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 21:11:37 PDT 2025

Total time taken to generate the page: 0.96228 seconds