Re: skip the corrupted hdf file and continue the for lood for uncorrupted hdfs [message #87356 is a reply to message #87355] |
Mon, 27 January 2014 21:37   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Brent Fallarcuna writes:
> I've run this code, wherein I inserted the for loop. The output on the command line says "MOD17A2.A2000065.h29v07.005.2010162162935.hdf
> Attempt to subscript FILENAME with K is out of range." and it only prints a single value.
>
> Perhaps IDL is confused with my code structure. Is it ok to use for loop within the for loop?
> What I needed is to identify those corrupted files (to re-download them again) and put the values in my csv output file.
Oh, dear. :-(
It is OK to use loops within loops if you have to, but I see no evidence
that you have to do so in anything you have told us or in this code. I
can't even figure out where the number 637 comes from. Doesn't the size
of your loop depend on how many files you have to open?
I would write something along these lines:
filelist = file_search('*.*.h29v07.005.*.hdf', Count=count)
array = StrArr(count)
FOR j=0,count-1 DO BEGIN
Catch, theError
IF theError NE 0 THEN BEGIN
void = cgErrorMsg()
Print, 'Bad File: ', filename[j]
Message, /Reset
Continue
ENDIF
thisFile = filelist[j]
hdf_id = hdf_sd_start(thisFile)
...
ENDFOR
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|