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

Home » Public Forums » archive » Re: how to read a data file
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: how to read a data file [message #48622] Wed, 03 May 2006 14:50 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
nalaka.kodituwakku@gmail.com wrote:
> Paul Van Delst wrote:
>> nalaka.kodituwakku@gmail.com wrote:
>>
>>> Yes, I did before puting this post but seems like there is some thing
>>> that i do wrong.
>>>
>>> This the code i wrote to read the first line. hopeing if this works i
>>> could write a loop to read the rest. but didn't work.Can some one see
>>> waht is wrong here? I tried with out the format too.this is the code
>>>
>>> pro import_test
>>>
>>> cts=INTARR(500)
>>> Lable1=STRARR(500)
>>> xvalues = fltarr(500)
>>> yvalues = fltarr(500)
>>> zvalues = fltarr(500)
>>> Atom=STRARR(500)
>>>
>>>
>>> openr, 105, 'sym1.mol2'
>>>
>>> readf, 105, c, l, x, y, z, a, format='(d2, A3, f5.4, f5.4, f5.4, a2)'
>>> print, c, l, x, y, z, a, format='(d2, a3, f5.4, f5.4, f5.4, a2)'
>>
>>
>>
>> what are c, l, x, y, z, a ?
>>
>> what error does IDL spit back at you?
>>
> As in the first post i have 6 coloums. I am trying to read the first
> row. so "c, l, x, y, z, a" are my 6 datas in first row.

Yes, but my point was that you do the following:
cts=INTARR(500)
Lable1=STRARR(500)
xvalues = fltarr(500)
yvalues = fltarr(500)
zvalues = fltarr(500)
Atom=STRARR(500)
but then use
c, l, x, y, z, a
to do the reading.

How is IDL to know what type each of those variables are? Maybe it can figure it out from
the context, but I doubt it (and wouldn't trust it if it could :o)

What happens if you do something like:

cts=INTARR(500) & c=cts[0]
Lable1=STRARR(500) & l=Lable1[0]
xvalues = fltarr(500) & x=xvalues[0]
yvalues = fltarr(500) & y=yvalues[0]
zvalues = fltarr(500) & z=zvalues[0]
Atom=STRARR(500) & a=Atom[0]

openr, 105, 'sym1.mol2'

readf, 105, c, l, x, y, z, a, format='(d2, A3, f5.4, f5.4, f5.4, a2)'
print, c, l, x, y, z, a, format='(d2, a3, f5.4, f5.4, f5.4, a2)'

?

paulv

p.s. I think I got the syntax right, but not sure.

p.p.s. Is "d2" a valid format specifier? Maybe you meant "i2"?

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Animation formats revisited
Next Topic: IDL source code formatter

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

Current Time: Wed Oct 08 17:36:37 PDT 2025

Total time taken to generate the page: 0.00442 seconds