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

Home » Public Forums » archive » Re: Loops in filenames?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Loops in filenames? [message #20086] Wed, 17 May 2000 00:00 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Bernard Puc wrote:
>
> Simon de Vet wrote:
>>
>> I have a number of text files, 'surfout.01', 'surfout.02' ...
>> 'surfout.12'.
>>
>> I can load any one of them into a 3-d array (model, longitude,
>> latitude). However, since each represents a different month, I would
>> like to put them all together into a 4-d array of (month, model,
>> longitude, latitude).
>>
>> The ackward method would be to just load each one in with its own little
>> code, changing the number each time. I know that there must be a better
>> way.
>>
>> Is it possible to load the files with a loop? I don't know where in the
>> help to look for such info, nor even where to start experimenting.
>
> ;To read a set of files
> filename = 'surfout.'
> EXT = ['01','02','03','04','05','06','07','08','09','10','11','12' ]
> for i = 0, 11 do begin
> openr,lun,/get_lun,filename+EXT[i]
> ;Read in values
> free_lun,lun
> endfor

Apologies for pickiness but wouldn't one prefer:

filename = 'surfout.'
for i = 0, 11 do begin
openr,lun,/get_lun,filename+STRING(i+1,FORMAT='(i2.2)')
;Read in values
free_lun,lun
endfor

?

It's a slow day....can you tell?
--
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.202, 5200 Auth Rd. Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Pretty-printing IDL code?
Next Topic: Loops in filenames?

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

Current Time: Sat Oct 11 22:08:59 PDT 2025

Total time taken to generate the page: 0.32198 seconds