I'm having a little trouble understanding the syntax for a Where Clause; e.g., for use in arcpy.Select_analysis(inSHP, clipSHP, where)
.
input is polygon shapefile; Zone_ID field is short integer
This works:
whereClause = '"Zone_ID"= ' + str(zone)
But this doesn't:
whereClause = "{field} = '{val}'".format(field = Zone_ID, val = zone)
Throws this error:
NameError: name 'Zone_ID' is not defined
"Zone_ID" is obviously defined because it works in the first case. Any ideas what's wrong with my syntax?
Tried this also:
whereClause = "{field} = '{val}'".format(field = "Zone_ID", val = zone)
Error message:
arcgisscripting.ExecuteError: ERROR 000358: Invalid expression Zone_ID = '1'
Failed to execute (Select).