Good day i learned arcpython from Programming ArcGIS 10.1 with Python Cookbook
I write script in the python window. This script add field CONFID_RATING but don't update this field.
Can you help me please
import arcpy, os
... arcpy.env.workspace="C:/ArcpyBook/Ch9/WildfireData/WildlandFires.mdb"
... try:
... #create a new field to hold the values
... arcpy.AddField_management("FireIncidents_1","CONFID_RATING","TEXT","10")
... print "CONFID_RATING field added to FireIncidents"
... with arcpy.da.UpdateCursor("FireIncidents",("CONFIDENCEVALUE","CONFID_RATING")) as cursor:
... cntr=1
... for row in cursor:
... # update the confid_rating field
... if row[0]<=40:
... row[1]='POOR'
... elif row[0] > 40 and row[0]<=60:
... row[1]='FAIR'
... elif row[0]>60 and row[0]<=85:
... row[1]='GOOD'
... else:
... row[1]='EXCELLENT'
... cursor.updateRow(row)
... print "Record number " + str(cntr) + " updated"
... cntr=cntr+1
... except Exception as e:
... print e.message
Why this field don't make update
Firstly,
use the advanced editor and the highlight python syntax -Click on that button which looks like ">>".
That would make your code easier to read.
Any errors messages?
Have you tried getting rid of the try/except blocks to see if it just errors out somewhere?
When you look at the data in the table, is "CONFIDENCEVALUE" how you expect it? Numeric?
Thank you for your answer.
I don't get any errors.
But only I get message "CONFID_RATING field added to FireIncidents"
And CONFIDENCEVALUE is Numeric.
I solved it. It was simply, i just only copy this feature class to gdb (WildlandFires.gdb). Then i get my result.