AnsweredAssumed Answered

Capture corrupt files and continue script

Question asked by cpoynter on May 30, 2013
Latest reply on Jun 16, 2013 by cpoynter
Hi All,

I am developing a script that walks a directory and sub-folders listing coverages, rasters and feature classes. Running successfully until it hits files that exist but not structured correctly / corrupted to be able to perform a describe function on.

I would like to capture these error files into a log file to check on them later, but have my script run to completition.

I have the following trying to capture error related files:

try:  <my code>  except arcpy.ExecuteError:              arcpy.AddError(arcpy.GetMessage(2))              f=open(r'D:\Temp\error.log', 'a')              f.write(item + "\\" + fileset)              f.close()

item represents path (e.g. "C:\Temp") and fileset is the file name (e.g. "data.shp").

Not sure what is happening as this seems to work elsewhere on the web I have seen referenced.

When I do a will usually halt the script with the problem file.

I just need coding to detect problem spatial datasets, list them for later checking and move on.