Re: creating multiple files [message #47364 is a reply to message #47363] |
Mon, 06 February 2006 20:55  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
bressert@gmail.com writes:
> I am currently writing a script in IDL where I'm trying to create
> multiple files. What is essentially being done is the following:
>
> 1) grabbing a large 4 by 400,000 matrix and then spliting it up by a
> specific criteria
>
> 2) splitting up the file will create about 12,000 different files
>
> 3) how do I routine a process where I can name a variable, i.e. sun'j'
> = ....
> where 'j' is an iterating number from 0 to 11,999.
>
> 4) afterwards, the script involves an openw and printf with file names
> of "sun'j'.dat".
>
> The last property that should be mentioned is that 'j' is a result of
> array processing. No loops are involved in the script.
>
> Thank you for regarding the inquiry and any advice would be greatly
> appreciated.
If "j" is any number between 0 and 11,999, and you want file
names like:
sun5.dat
sun195.dat
sun11493.dat
Then you simply create your filename like this:
filename = 'sun' + StrTrim(j,2) + '.dat'
If you want filenames like this:
sun00005.dat
sun00195.dat
sun11493.dat
Then you create your filename like this:
filename = 'sun' + String(j, Format='(I5.5)') + '.dat'
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|