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

Home » Public Forums » archive » Re: need a quicker way to read ascii file w/a structure
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: need a quicker way to read ascii file w/a structure [message #25336] Wed, 06 June 2001 12:22 Go to previous message
dirk is currently offline  dirk
Messages: 15
Registered: March 1998
Junior Member
In article <003701c0ee21$447c6b70$d938a8c0@hadfield>,
Mark Hadfield <m.hadfield@niwa.cri.nz> wrote:
> From: "Lucas Miller" <differentiable@hotmail.com>
>> OK. I've got an ascii file laid out in columns with a string in the
>> first column, like this
>>
>> yyyy-ddd // hh:mm:ss.ms 0 12 -1.00 -1.00 -1.00 -1.00
>> (lots and lots of rows)
>>
>> I defined a structure
>> mystruct = {utctime: ' ',mpos: 0, sector: 0,$
>> arate: 0.0, brate: 0.0, crate: 0.0, drate: 0.0}
>>
>> I know the number of rows so I replicate,
>> data = replicate(mystruct,num_of_rows)
>>
[snip]
>
> Yes, because mystruct.utctime is a string and strings are "greedy" in read
> operations unless the field width is specified explicitly.
>
> yyyy-ddd // hh:mm:ss.ms 0 12 -1.00 -1.00 -1.00 -1.00
>
[snip]
> I have written a lot of routines to process text data files and I have found
> that the formats are so variable and loosely defined that a general solution
> is not possible and not worth attempting.

I have had a lot of success with the function readcol.pro found on the
idlastro archives. http://idlastro.gsfc.nasa.gov/contents.html

Get all the supporting programs for this, it's worth it.

Basically, it will separate each line into tokens of various type and
stick those values in arrays that you speciify. It will be easy to put
them in the structure from there. Since it is based on the token idea, it
can deal with varying formats, as long as there are spaces between the
tokens.

Good luck.

- Dirk
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: resizing an array of structures (uugh)
Next Topic: Specific cross platform IDL problem...

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

Current Time: Wed Oct 08 15:36:23 PDT 2025

Total time taken to generate the page: 0.00429 seconds