I have a shapefile and I want to loop through every column and extract selected features with the specified criteria (Column has a P or L).
So my code is like
output = "All.shp"
fields = arcpy.ListFields(output)
for field in fields:
arcpy.MakeFeatureLayer_management("all.shp", "lyr")
name = field.name
clause = name + " LIKE 'P' OR "+ name + " LIKE 'L'"
arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", clause)
arcpy.CopyFeatures_management("lyr", field.name+".shp")
Clause seems to fail, triedfails with ExecuteError: ERROR 000358: Invalid expression. Tried different things but not working!