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 #25350 is a reply to message #25336] Wed, 06 June 2001 00:03 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Mark Hadfield 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)
>>
>> and I read,
>> readf, myfilelun, data
>>
>> and find out that the entire row is read into my mystruct.utctime
>> string variable.
>
> 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
>
>> I don't want to use an
>> explicit format statement because the format varies....
>
> That's a pity. If the widths of the fields were fixed then an explicit
> format would work.
>
> Have you considered going to the person who generated the text files and
> suggesting she produce them with fixed widths. While you're at it, ask her
> why she couldn't have done that in the first place.

The best is to ask about a non string date/time identifier.
For example you can use seconds or julian seconds.
julian seconds are defined by Ray Sterner
as seconds since 2000-1-1 00:00:00 UTC.

For this timeformat are lots of routines available to format them
in other time formats.

regards

Reimar


>
>> ...The only thing I can think of doing at
>> this point is reading my file in as a string array, separating it into
>> variables, and feeding it into my structure.
>
> Well, you don't have to load the entire file into an array, you can read
> each line into a scalar string, get the data you want and load it into the
> output array, then discard the line.
>
>> This would
>> take a LOT of time...
>
> Not all that much in my experience. Read each line, split off the time
> string, read the numbers out of the remainder with a reads statement--it
> wouldn't take much longer to write the code than to describe it.
>
>> ...and besides isn't there a more elegant way to do
>> it?
>
> Not that I can think of.
>
> 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.
>
> ---
> Mark Hadfield
> m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
> National Institute for Water and Atmospheric Research
>
> --
> Posted from clam.niwa.cri.nz [202.36.29.1]
> via Mailgate.ORG Server - http://www.Mailgate.ORG

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
[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: Fri Oct 10 09:23:31 PDT 2025

Total time taken to generate the page: 6.56109 seconds