| Formatted Reads of Arrays [message #20484] |
Fri, 30 June 2000 00:00  |
wcapehar
Messages: 12 Registered: May 1998
|
Junior Member |
|
|
For ages I have had to use dummy variables to read formatted data into
an array so that, for example,
for a loop value "i"
readf, 1, rplace, rvalue1, rvalue2, rcode1, rcode2, $
format='(A5,F5.3,I6,2A3)'
place(i) = rplace
value1(i) = rvalue1
value2(i) = rvalue2
rcode1(i) = rcode1
rcode1(i) = rcode2
If all the values were the same type, then I could just read them in as
a big array block and then parse with wildcards. But the mix of
characters and integers in this file requires the personal attention.
Are there any tricks to do this more efficiently or at least drop the
dummy variables?
Thanks much...
Bill
Sent via Deja.com http://www.deja.com/
Before you buy.
|
|
|
|
| Re: Formatted Reads of Arrays [message #20559 is a reply to message #20484] |
Wed, 05 July 2000 00:00  |
promashkin
Messages: 169 Registered: December 1999
|
Senior Member |
|
|
Bill,
I think than the simpliest thing to do is to read into strings and
STRSPLIT, then convert data types. I also had success reading into
structures. This works if the last part of lines is characters. If first
fields of a structure are strings, then automated formatting for READF
in IDL reads the whole line into a string and more sophisticated
formatting was required.
Cheers,
Pavel
> But the mix of
> characters and integers in this file requires the personal attention.
> Are there any tricks to do this more efficiently or at least drop the
> dummy variables?
|
|
|
|