Sunday 7 April 2019

arcpy - What causes ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute) on shapefile?



My script runs perfectly for feature classes, but not shapefiles. It crashes at the point of selection, provided there is a query.


gp.Workspace = "C:/someworkspace"
fc = "featureclass.shp"
query = "[SOME_TEXT_FIELD] = \"666\""
gp.MakeFeatureLayer(fc, "flyr")

gp.SelectLayerByAttribute("flyr", "NEW_SELECTION", query)

returns



ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).



Tested a similar simple example in the Python Shell. This runs fine with a geodatabase and feature class. I assume there is some sort of special treatment for shapefiles I'm not aware of, but arcgis desktop help does not specify anything.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...