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 #70167 is a reply to message #70069] Sat, 13 March 2010 18:03 Go to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
"Adam Solomon" <ramparts@gmail.com> wrote in message
news:e5bdbfda-121a-41fb-8204-57764e0cc70d@g10g2000yqh.google groups.com...
On Mar 13, 8:04 pm, David Fanning <n...@dfanning.com> wrote:
> Adam Solomon writes:
>> Hi all, I've been pulling my hair out over using readf with a format
>> code. So I have a data file with three columns of floats, all
>> separated by a |. Here's an example:
>
>> | 355.9559189095| -79.4625574877| 0.279817 |
...
> rows = File_Lines('example.dat')
> data = DblArr(3,rows)
> oneLine = ""
> OpenR, lun, 'example.dat', /GET_LUN
> FOR j=0,rows-1 DO BEGIN
> ReadF, lun, oneLine
> parts = StrSplit(oneLine, '|', /EXTRACT)
> data[*,j] = Double(parts[1:3])
> ENDFOR
> Free_Lun, lun


Yep. Always use the same rules to read, as you do to write.
If they wrote it with a format, you read it with the same format.
If they wrote "stuff" and then "|", then that is how you read it
(as David has shown).


btw, one suggestion. perhaps you can write a Convert program
to read this huge ascii data set once, and write it in a quick binary
format (perhaps as a structure with all pertinent information).

cheers,
bob
[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: Sun Oct 12 13:44:19 PDT 2025

Total time taken to generate the page: 0.56067 seconds