Re: Filling array in loop [message #77004] |
Mon, 18 July 2011 11:53  |
Alexa
Messages: 8 Registered: June 2011
|
Junior Member |
|
|
On Jul 18, 2:46 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jul 18, 3:06 pm, Alexa <alexa7...@gmail.com> wrote:
>
>
>
>> Hi All,
>
>> I'm trying to write a routine that loops through folders, grabs data
>> from each folder, and makes one large array out of all the
>> information. This is what I'm currently trying,
>
>> ;;Open file with list of metallicities and put into an array
>> ReadCol, "MetalsList.txt", Metal, Format='a'
>> print, Metal
>
>> ;;Create temporary arrays for the transitions
>> Result=FLTARR(41, 25)
>
>> ;;Open the metals folders in order to read in col.txt
>
>> for nt=0, N_ELEMENTS(Metal)-1 do begin
>> cd, Metal[nt]
>> print, Metal[nt]
>> ;;Read in column densities
>> ReadCol, 'Result.cd', U, result, Format='a'
>
>> cd, '..'
>
>> ;Fill arrays
>
>> Result(nt)=[U, result]
>> print, Result
>> endfor
>
>> But instead of one large array, I get a smaller array for each folder.
>> Any suggestions on how I can fix this?
>
> On each pass through the line
>
> ReadCol, 'Result.cd', U, result, Format='a'
>
> I would expect (I do not know the details of readcol) the array result
> to be reassigned, containing just what was read, throwing out whatever
> was in it before. If so, you can just use another variable for
> readcol.
Thanks! I just remembered that IDL doesn't care about capitalization.
|
|
|