instead of whereClause = ('"' + crimeField + '" <=' + "'" + crimefieldindex + "'") try myfield1 = arcpy.AddFieldDelimiters(lyr,crimeField) whereClause = '{0} <= '{1}''.format(myfield1,crimefieldindex)
import arcpy from arcpy import env env.overwriteOutput = 1 env.workspace = r"C:\Temp\Python\Test.gdb" citiesL = "citiesL" crimeField = "CRIME_INDE" crimefieldindex = "0.02" whereClause = '"' + crimeField + '" <=' + "'" + crimefieldindex + "'" universityField = "UNIVERSITY" universityfieldindex = "1" whereClause2 = '"' + universityField + '" =' + "'" + universityfieldindex + "'" arcpy.MakeFeatureLayer_management("Cities", citiesL) arcpy.SelectLayerByAttribute_management(citiesL, "NEW_SELECTION", whereClause + "AND" + whereClause2) arcpy.CopyFeatures_management(citiesL, "Cities2")
whereClause = '"' + crimeField + '" <=' + "'" + crimefieldindex + "'" whereClause2 = '"' + universityField + '" =' + "'" + universityfieldindex + "'"
arcpy.SelectLayerByAttribute_management(citiesL, "NEW_SELECTION", whereClause + "AND" + whereClause2)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.