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

Home » Public Forums » archive » Re: idl readf error
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: idl readf error [message #65121] Sat, 14 February 2009 06:35 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Feb 13, 10:17 pm, David Fanning <n...@dfanning.com> wrote:
> rollo.tom...@hotmail.com writes:
>> Here's what I have:
>
>> IDL> openr, 1, 'file1.out'
>> IDL> h = strarr(5)
>> IDL> readf, 1, h
>> IDL> close, 1
>> IDL> for j=0,4 do print, h[j]
>> T       U       17.81   201     145225.9
>> T       U       37.67   191     98975.8
>> T       U       21.77   201     129774.9
>> T       I       0.65    1       69.5
>> T       I       0.36    1       69.3
>
>> By doing this I noticed that the values in the last column get pretty
>> large, so I changed the format to
>> format='(2A2, G7.2, G7.2, G10.2)'
>
>> And I still get the same error.
>
>> The largest values in the numerical columns are:
>> column 3: 272.23
>> column 4: 1000
>> column 5: 145225.9
>
> OK, well, as I expected, that format does not correspond
> to what is in the file. And I am still mystified as to
> why it worked (if it did) initially. The format looks to
> me to be something more like this:
>
>    format='(2(A1,7x),F5.2,3x,I3,5x,G8.2)'
>
> Try that and see if you have better luck. :-)
>
> Here is the code I used to read the first line:
>
> IDL> openr, 1, file
> IDL> a="" &b = "" & c=0.0 & d=8 & e=0.0
> IDL> readf, 1, a, b, c, d, e, format='(2(A1,7x),F5.2,3x,I3,5x,G8.2)'
> IDL> print, a, b, c, d, e
> TU      37.6700     191      98975.8
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

This thread makes me think... Can anyone compare and contrast this
approach with the approach I usually use - that is:
read each line into a string buf: buf = '' $ readf, lun, buf
then use strsplit(buf,/extract) to chop up the buf
then use fix, float, etc. to get the values.

I don't usually use format statements for reading, just writing.

Thanks,
Vince
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: happy 1234567890 day!
Next Topic: Reading multiple ASCII files in as 2d arrays and putting them into a 3d array

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

Current Time: Sat Oct 11 16:37:27 PDT 2025

Total time taken to generate the page: 1.91619 seconds