Hi,
I'm new to IDL, programming, and usenet groups, so please forgive me
if I do something wrong... I found a thread with a similar problem
(from 2006), and I initially replied in that thread, but I can't see
the post so I'm starting a new thread.
The problem I have is as thus:
I have 125 ASCII files, of varying row length, and I want to read them
into 3-d array. So far I have this:
FOR i=1,125 do begin
infile = string(i,format='("LCgen/20090127/",i3.3,".dump")')
OPENR,lun,infile,/GET_LUN
rows = FILE_LINES(infile)
data = fltarr(10,70,125)
framearray = fltarr(10,rows)
READF,lun,format ='(I2,1x,I2,1x,I2,2x,F0,2x,I0,5F0.3)',framearray
close,lun
free_lun,lun
;data[10,*,i] = framearray
print,framearray
ENDFOR
I've tried two approaches. First of all, I've tried reading each file
into the array 'framearray', and then subsequently (within the loop)
placing the 2-d array (framearray) into the 3-d array (data), with
something like this:
data[*,*,i] = framearray
but this complains that array is the wrong size. (I assume its
possible to put a smaller array into a larger array without IDL
complaining - I figured it would fill the rest of the space with
zeros?).
The other approach I've tried (but I don't know the syntax) is to
change the name of 'framearray' with each pass of the loop, i.e. with
something like
readf,lun,'framearray'+strtrim(i,2)
but I get an error saying something like : 'Attempt to store into an
expression: <STRING blah'
in supermongo, I would be able to refer to the value of the loop index
with '$i', but I'm not sure how I do that in IDL....
i.e. take the loop index (which I assume is automatically an integer),
make it a string, concatenate with the array prefix, and turn the
whole thing back into an expression that READF will digest...
i.e. I will end up with 125 arrays, framearray1 - framearray125.
Can anyone help (or understand my rambling)?
Thanks,
Stefan
|