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

Home » Public Forums » archive » Re: How to read first and last line of an ascii file FAST
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: How to read first and last line of an ascii file FAST [message #72409 is a reply to message #72335] Tue, 31 August 2010 09:08 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Am 29.08.2010 18:32, schrieb Heinz Stege:
> On Sun, 29 Aug 2010 08:32:15 -0700 (PDT), ahs wrote:
>
>> Hello group,
>>
>> My data is stored in a bunch of ascii files, each 5-10MB big. Each
>> line represent a sample with a timestamp. I would like to analyse all
>> my files by reading the timestamp from the first and last line of
>> every file. Getting the timestamp from the last line is the issue
>> here. Right now I'm doing it like
>>
>> readf, fid, firstline
>> nlines = FILE_LINES(fnames[i])
>> skip_lun, fid, nlines-2, /LINES
>> readf, fid, lastline
>>

did you tried reading the file in one string array of len file_lines


IDL> f = "example.txt"
IDL> n = file_lines(f)
IDL> data = make_array(n,/string)
IDL> openr, lun, /get_lun, f
IDL> readf, lun , data
IDL> free_lun, lun
IDL> print, data[n-1]

that needs 0.05 seconds to get that information

Reimar


>> skip_lun is really slow when the files are big and numerous. Does
>> anyone have a tip of I could do this faster? Is there a way to
>> directly point to the end of the file minus one line?
>>
>> regards,
>> Agnar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: about the blackbody radiation curve
Next Topic: Re: how to change button names on the dialog_message

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

Current Time: Thu Oct 09 15:24:18 PDT 2025

Total time taken to generate the page: 0.08133 seconds