I would like to create a query in ArcPy without creating a temporary additional attribute first. Unfortunately I fail with the syntax for creating the expression. I want to check if a ratio of two existing attributes (RCT_WIDTH_MBG_Length_REWI and RCT_WIDTH_MBG_Width_REWID) falls below a certain value.
My latest code is:
expression = '!RCT_WIDTH_MBG_Length_REWI! / !RCT_WIDTH_MBG_Width_REWID! > 3'
arcpy.SelectLayerByAttribute_management('Clean_LYR', 'NEW_SELECTION', expression)
if int(arcpy.GetCount_management('Clean_LYR')[0]) > 0:
print(str(int(arcpy.GetCount_management('Clean_LYR')[0])) + ' werden geloescht')
arcpy.DeleteFeatures_management('Clean_LYR')
and during the script run I code the error message:
ExecuteError: ERROR 000358: Invalid expression