I've been running a code that searches a desired field in a feature class and performs an specified SQL query based on whether the field is string or double. The variables are just temporary fillers to test the code, I'll be shifting them to GetParameterasText() as soon as I know that all of the code works. I need the code to work so that it can be turned into a ArcGIS toolbox script.
import arcpyfrom arcpy import envenv.overwriteOutput = True#Create working variablesfc = "C:/gisclass/assignment5/Results/CITIES.shp" #vector feature classaffectedField = "CAPITAL"oldValue = -1newValue = 2integer = 0fieldlist = arcpy.ListFields(fc)for field in fieldlist: if field.type == "String": queryString = """"%s" LIKE '%s'"""%(affectedField, oldValue) or """%s" = '%s'"""%(affectedField, oldValue) elif field.type == "Double": queryString = """"%d" >= '%d'"""%(oldValue, integer) or """"%d"
import arcpyfrom arcpy import envenv.overwriteOutput = True#Create working variablesfc = "C:/gisclass/assignment5/Results/CITIES.shp" #vector feature classaffectedField = "CAPITAL"oldValue = -1newValue = 2integer = 0fieldlist = arcpy.ListFields(fc)for field in fieldlist: if field.type == "String": queryString = """"%s" LIKE '%s'"""%(affectedField, oldValue) or """%s" = '%s'"""%(affectedField, oldValue) elif field.type == "Double": queryString = """"%d" >= '%d'"""%(oldValue, integer) or """"%d"