if statement - If-else populate field error in Python (arcpy) -
i'm trying learn python , writing arcpy script arcgis 10.1. objective check variety of fields absent value (-99) , populate newly added field 0 value. code runs...however populates values 6 value. 6 part of problem, other part being i've checked , there should 3 (-99) values in table.
below code. # import arcpy module import arcpy print "start engines" # script arguments shapefile = "c:\\gislab2\\python\\take_home\\uscancer2000.shp" #this arcpy.userargument part goes, re-exporting model. field_name = "henry1" output_feature_class = "c:\\gislab2\\python\\take_home\\uscancer2000.shp" # local variables: uscancer2000__2_ = output_feature_class # process: add field arcpy.addfield_management(shapefile, "henry1", "long", "", "", "", "", "nullable", "non_required", "") # process: calculate field arcpy.calculatefield_management(output_feature_class, "henry1", "5.5", "python_9.3", "") ## ### process: if-then check missing values ## if "cnt1"==-99: field_name=0 elif "cnt2"==-99: field_name=0 elif "cnt3"==-99: field_name=0 elif "pop1"==-99: field_name==0 elif "pop2"==-99: field_name=0 elif "pop3"==-99: field_name=0
you comparing constants in code.
is "cnt1"==-99 ??
that never true.
i not know arcpy, if want parse results functions should returned value or inspect variables passed parameters after call.
Comments
Post a Comment