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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: how to read a data file [message #48622] Wed, 03 May 2006 14:50 Go to next 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
Re: how to read a data file [message #48624 is a reply to message #48622] Wed, 03 May 2006 14:05 Go to previous messageGo to next message
nalaka.kodituwakku is currently offline  nalaka.kodituwakku
Messages: 4
Registered: May 2006
Junior Member
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.

The error i get is
READF: Input file conversion error. unit : 105 File sym1.mol2


thank you very much for your time

Nalaka
Re: how to read a data file [message #48625 is a reply to message #48624] Wed, 03 May 2006 13:40 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  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 Go to previous messageGo to next message
nalaka.kodituwakku is currently offline  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
Re: how to read a data file [message #48636 is a reply to message #48626] Wed, 03 May 2006 01:05 Go to previous messageGo to next message
Peter Clinch is currently offline  Peter Clinch
Messages: 98
Registered: April 1996
Member
nalaka.kodituwakku@gmail.com wrote:
> I am new bee to IDL
>
> I have a data set look like

<snip>

> Can some one tell me how to write IDL code to read this data in a
> formatted way?

Have a look in the User Guide (online of paper). "Getting Started With
IDL" includes "Reading and Writing Data".

READF and READ_ASCII are functions to look at.

Pete.
--
Peter Clinch Medical Physics IT Officer
Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital
Fax 44 1382 640177 Dundee DD1 9SY Scotland UK
net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
Re: how to read a data file [message #48683 is a reply to message #48622] Mon, 08 May 2006 07:26 Go to previous message
nalaka.kodituwakku is currently offline  nalaka.kodituwakku
Messages: 4
Registered: May 2006
Junior Member
Thanks guys,

It did work, both i2 and d2 are work too. Still I don't know the
different between them.
thank you very much for your time

Nalaka.
  Switch to threaded view of this topic Create a new topic Submit Reply
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 15:52:15 PDT 2025

Total time taken to generate the page: 0.00705 seconds