Re: Read these data in structure [message #71783] |
Wed, 21 July 2010 23:36  |
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
|
|
|