Re: how to read a data file [message #48622] |
Wed, 03 May 2006 14:50  |
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
|
|
|
|
Re: how to read a data file [message #48625 is a reply to message #48624] |
Wed, 03 May 2006 13:40   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
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?
> close, 105
> free_lun,105
> END
>
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
|
|
|
Re: how to read a data file [message #48626 is a reply to message #48625] |
Wed, 03 May 2006 13:34   |
nalaka.kodituwakku
Messages: 4 Registered: May 2006
|
Junior Member |
|
|
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)'
close, 105
free_lun,105
END
|
|
|
|
|