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

Home » Public Forums » archive » Re: Reading a set of data with string type entries
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: Reading a set of data with string type entries [message #57073 is a reply to message #57072] Fri, 30 November 2007 04:53 Go to previous messageGo to previous message
rkombiyil is currently offline  rkombiyil
Messages: 59
Registered: March 2006
Member
On Nov 30, 2:44 pm, mystea <idllear...@gmail.com> wrote:
> Dear all,
>
> I need to read in a large set of data. Each entry is started with a
> name, followed by many numbers.
> The numbers are separated by spaces, but the length of each number is
> not fixed.
>
> My problem is like this: Since the data starts with a string, I can't
> use free-format readf (because by default, the string slot will read
> the whole line.) and due to the unknown length of numbers, I can't use
> a format code, either.
>
> What should I do?
>
> Gene

Don't know if one has to resort to regex... I suggest using
"structures" to read variable length data as "string variables and
specify format as floats". I use this method to read satellite data
where the length of the "same datum" is "not fixed.

For example, I have used the following and worked for me. The "a"
format is where the variable length numbers are ---> so I counted the
total number of spaces from the end of one datum to end of, and
including the next datum, which is variable - and this space is
"fixed" (this fixed space is specified by the "a" format, and when you
declare them as floats, you get the variable length datum only, minus
the empty spaces). So count the space separating and including the
variable length datum :)
----
fmt='(2(i2,1x),i4,2(1x,i2),7x,2(a15),a16)'
followed by the record structure
record={dd:0L,mo:0L,yyyy:0L,hh:0L,mm:0L,AA:0.0,BB:0.0,CC:0.0 }
----
Then the whole datafile consisting of various records can be read,
each with the same format as above.

Hope this helps,
/rk
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: about widgets
Next Topic: Re: IDL 7.0 .... any new functions?

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

Current Time: Wed Oct 08 18:56:56 PDT 2025

Total time taken to generate the page: 0.00446 seconds