I have this code:
... for table in tableList:
... with arcpy.da.SearchCursor(table, ["qname","tname","query"]) as cur:
... for row in cur:
... if row[2] not in ('',None):
... query = row[2]
... arcpy.Select_analysis(in_features=row[1],
... out_feature_class=os.path.join(shapefile_output_folder,row[0]),where_clause=query)
If a certain file that meets at the loop doesn't exist I want to print the name of the file and continue without stopping.
The error when it doesn't find the file is :
Runtime error Traceback (most recent call last): File "", line 8, in File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\analysis.py", line 90, in Select raise e ExecuteError: ERROR 000732: Input Features: Dataset TA2a does not exist or is not supported
So how should the exception be? I tried:
try
... for table in tableList:
... with arcpy.da.SearchCursor(table, ["qname","tname","query"]) as cur:
... for row in cur:
... if row[2] not in ('',None):
... query = row[2]
... arcpy.Select_analysis(in_features=row[1],
... out_feature_class=os.path.join(shapefile_output_folder,row[0]),where_clause=query
)
except arcpy.RuntimeError:
print(table)
Can you suggest corrections?
for table in tableList:. Out of curiosity, how is tableList being populated?tableList = [os.path.join(table_workspace, table) for table in arcpy.ListTables("table1w")]