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 data with format codes?
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 data with format codes? [message #70068] Sat, 13 March 2010 17:45 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Mar 13, 10:20 pm, Adam Solomon <rampa...@gmail.com> wrote:
> Thanks! I was going to do that but I read on this website - dfanning
> something or other - to avoid for loops in IDL :) Figured a format
> code would save time since there's on the order of 10^6 data points
> here, but I guess that's nothing compared to all the time I'm spending
> writing the damn code!

In this case, it is too awkward to avoid a loop. It would be easy if
strpos accepted an array as its pos argument (which it really should,
to work nicely with strmid):

nlines=file_lines(file)
a=strarr(nlines)
openr,unit,file,/get_lun
readf,unit,a
free_lun,unit
;Get rid of the initial |
pos=transpose(strpos(a,'|'))
a=strmid(a,pos+1)
;Extract the first column
pos=transpose(strpos(a,'|'))
col1=double(strmid(a,0,pos))
a=strmid(a,pos+1)
;Extract the second column
pos=transpose(strpos(a,'|'))
col2=double(strmid(a,0,pos))
a=strmid(a,pos+1)
;Extract the third column
pos=transpose(strpos(a,'|'))
col3=double(strmid(a,0,pos))
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Calculate gradient
Next Topic: Re: Find out which area is covered in a map plot

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

Current Time: Sat Oct 11 05:09:10 PDT 2025

Total time taken to generate the page: 2.07734 seconds