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

Home » Public Forums » archive » Re: FindFile for more than one filetype
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: FindFile for more than one filetype [message #28578 is a reply to message #28575] Thu, 20 December 2001 13:05 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Sue wrote:
>
> Hello,
>
> I have a folder full of *_average.int files where the * represents
> different years (1981-2000).
>
> I am trying to make it so that my variable, filelist, equals two
> files: (1)1981_average.int and (2)1982_average.int and then the next
> time, filelist equals: (1)1982_average.int and (2)1983_average.int and
> so on. It is also important that I get the filecount to equal 2.
>
> However, I can not figure out how to do it using the FindFile function
> using the IDL language.
>
> This is what I have so far...(of course there is other stuff in btwn)
>
> for yr = 1981, 2000 do begin
>
> filelist = FINDFILE(outpath + string(yr, FORMAT = '(I4.4)')
> + '*'+ '_average.int', COUNT=filecount)
> and
> FINDFILE(outpath + string(yr+1, FORMAT = '(I4.4)')+ '*'
> + '_average.int', COUNT=filecount)
>
> endfor
>
> trying to use the "AND" here gives me an error about how strings can
> not be used in this way or something but I left the code up here so
> that the concept of what I want to achieve is clear.
>
> Thanks.
> Sue

Why not do:

; -- Get the list of all the files you want
all_files = FINDFILE( outpath + '*_average.int', COUNT = n_files )

; -- Set the start year
start_year = 1981L

; -- Loop over blocks of two files
FOR i = 0L, n_files - 2L DO BEGIN

; -- Indices for the two files you want
index = [ i, i+1 ]

; -- Years for the two files you want
year = LONG( index ) + start_year

; -- Pluck 'em out
filelist = all_files[ index ]

; -- Do stuff with 'em
......

ENDFOR

Will this work? The files should be in the correct order since their prefix is the year number
- but you might want to do a sort anyway to check before you enter the loop. You can also
extract out the year from the file name string if needs be but adding the index seems to be
easier.

paulv

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Pointer syntax and IDL 4.0: summary
Next Topic: Wiener filter

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

Current Time: Wed Oct 08 15:56:37 PDT 2025

Total time taken to generate the page: 0.00385 seconds