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

Home » Public Forums » archive » Re: Read these data in structure
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: Read these data in structure [message #71783] Wed, 21 July 2010 23:36
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Jul 21, 3:49 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Jul 21, 3:33 am, ali mozafari <a.mozafari1...@googlemail.com>
> wrote:
>
>
>
>
>
>> Folks
>> I have a question:
>> I have some *.dat files (it is changing each time and I do not know
>> how many I have) and also rows and columns of *.dat files are
>> different. I want to read these data in structure. I tried something
>> like this:
>> pro read_several_files
>> path="d:\p\"
>> List = findfile(path+"*.dat")
>> no=N_ELEMENTS(List)
>> info={info:ptr_new(/allocate_heap)}
>> for i = 0, no-1 do info.info=read_ascii(list[i])
>> ……
>> What I need is at the final I get structure that I can access my data.
>> Data1=…
>> Data2=….
>> …..
>> Any Help?
>
> Why not use a pointer array instead?
>
> files = file_search('search string', count = ct)
> data = ptrarr(ct)
> for i = 0, ct - 1 do begin
>  x = ...code to read your file into an array...
>  data[i] = ptr_new(x)
> endfor
>
> then, you access each file's array by *(data[i])
>
> chris

But *(data[i]) is a structure and you need:
data=*(data[i]).(0)
Cheers
Dave
Re: Read these data in structure [message #71785 is a reply to message #71783] Wed, 21 July 2010 15:49 Go to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
On Jul 21, 3:33 am, ali mozafari <a.mozafari1...@googlemail.com>
wrote:
> Folks
> I have a question:
> I have some *.dat files (it is changing each time and I do not know
> how many I have) and also rows and columns of *.dat files are
> different. I want to read these data in structure. I tried something
> like this:
> pro read_several_files
> path="d:\p\"
> List = findfile(path+"*.dat")
> no=N_ELEMENTS(List)
> info={info:ptr_new(/allocate_heap)}
> for i = 0, no-1 do info.info=read_ascii(list[i])
> ……
> What I need is at the final I get structure that I can access my data.
> Data1=…
> Data2=….
> …..
> Any Help?

Why not use a pointer array instead?

files = file_search('search string', count = ct)
data = ptrarr(ct)
for i = 0, ct - 1 do begin
x = ...code to read your file into an array...
data[i] = ptr_new(x)
endfor

then, you access each file's array by *(data[i])

chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Decomposing a bit field?
Next Topic: Batch mode and ssh...

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

Current Time: Wed Oct 08 19:42:40 PDT 2025

Total time taken to generate the page: 0.00684 seconds