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

Home » Public Forums » archive » Re: reading an ascii file efficiently
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: reading an ascii file efficiently [message #68905 is a reply to message #68904] Fri, 27 November 2009 19:16 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Fri, 27 Nov 2009 11:02:45 -0800 (PST), nata wrote:

> Hi all,
>
> Thanks for your suggestions. Finally, the fastest read time for this
> situation is the following one:
>
> lines=FILE_LINES(file)
> rr=STRARR(lines)
> OPENR, lun, file, /GET_LUN
> READF, lun, rr
> FREE_LUN, lun
>
> result=FLTARR(lines)
> FOR i=0l, lines-1 DO BEGIN
> str_arr=STRSPLIT(rr[i],',',/EXTRACT)
> result[i]=FLOAT(str_arr[6])
> ENDFOR
>
> It's just 0.4 seconds faster than the previous solution. Thanks,
> anyway
>
> nata

What do you think about replacing the for-loop (and the initial array
definition). I would expect the following method to be significantly
faster:

pos=strpos(rr,',',/reverse_search)
result=float(strmid(rr,transpose(pos)))

Have fun, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Larger arrays or more dimensions?
Next Topic: SHAPEFILE changes in IDL7.1?

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

Current Time: Sat Oct 11 04:37:09 PDT 2025

Total time taken to generate the page: 0.72058 seconds