Following on from Correct SQL expression for SelectbyAttribute Tool, I have my code:
import arcpy
plantFile = r"U:\Users\K\Plants.shp"
field = "UID"
arcpy.MakeFeatureLayer_management (plantFile, "plant_temp")
expression = round("UID" / 2, 0) <> "UID" / 2
arcpy.SelectLayerByAttribute_management("plant_temp", "NEW_SELECTION", expression)
I encounter -- TypeError: unsupported operand type(s) for /: 'str' and 'int'
"UID" is a long integer field, so I'm not understanding why this is happening. I've looked up methods for changing types for individual values, but not for an entire field. I will also be running this on over 20,000 records, so processing time is a concern.
EDIT I applied the suggested expression expression = '''round("UID" / 2, 0) <> "UID" / 2'''
which returned ExecuteError: ERROR 000358: Invalid expression
No comments:
Post a Comment