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

Home » Public Forums » archive » 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
reading an ascii file efficiently [message #68917] Fri, 27 November 2009 10:11
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
Hi guys,

I'm reading an ascii file and I can do that using different methods.
Now, I'm trying to use the most efficiently method. I do something
like this:

lines=FILE_LINES(file)
rr=STRARR(lines)
OPENR, lun, file, /GET_LUN
READF, lun, rr
FREE_LUN, lun

Now i have all the information in rr variable. Each line have the
following information:
280 , 0 , 280 , 0 , -58.085 , -32.616 , -32.000
or
15 , 1 , 15 , 1 , -60.908 , -32.603 , -32.000

And I need to return only the last value, so -32.000. I can use
STRSPLIT or STRMID with STRPOS but is not efficient so I'm trying to
use READS for each line. Something like this:

aux=0.
result=FLTARR(lines)
FOR i=0l, lines-1 DO BEGIN
READS, rr[i], aux, aux, aux, aux, aux, aux, aux,
FORMAT='(F0,",",F0,",",F0,",",F0,",",F0,",",F0,", ",F0,",",)'
result[i]=aux
ENDFOR

You can see that I don't know how to use the FORMAT keyword properly
so maybe you have an idea of how to skip the first 6 values.
Using a template, strsplit, etc. I found that this is the most
efficient way to read this *@#$* file.

Thanks if you can help me with this format or if you have a
suggestion.

nata
[Message index]
 
Read Message
Previous Topic: IDL-Widget
Next Topic: Greek Letters

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

Current Time: Sat Oct 11 02:16:11 PDT 2025

Total time taken to generate the page: 8.72088 seconds