Hello All,I am working on an update cursor on a contour line feature class. The goal is to update a field "INDEX_VALU" with the string "10 foot Index" where data in the "CONTOUR" field are divisible by 10. In tests I was success when setting a simple query as shown:query = ' "CONTOUR" = 5100'
The issues occurs when I try to modify this query to include all values divisible by 10. I believe the modulo operator is the way forward, but they query keeps getting rejected. Enclosed is my latest attempt at solving this. Any help will be appreciated.# Script Name: contourindexcalc.py # Author: Stephen Gushue # Purpose: Find and calculate values of the contours to illustrate 10 foot contours # Import system modules import arcpy, sys, traceback from arcpy import env # Set workspace arcpy.env.workspace = 'U:\\GEO\\projects\\python' # Local Variables featureclass = 'contours_test.shp' fieldlist = arcpy.ListFields (featureclass) try: # Sets row hold query setfield = '"CONTOUR"%' query = 'setfield == 0' # Create a Search Cursor srows = arcpy.SearchCursor (featureclass, query) for srow in srows: # assign a variable for the value of srow.CONTOUR # assign a variable for the value of srow.INDEX_VALU contour = srow.CONTOUR index = srow.INDEX_VALU # Create Update Cursor urows = arcpy.UpdateCursor(featureclass, query) # Cycle through the rows # to actually update the row in the cursor # with the values obtained from the search cursor for urow in urows: urow.INDEX_VALU = "10 Foot Index" urows.updateRow(urow) print 'DONE' del urow, urows, srow, srows except: tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n" msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(msgs) arcpy.AddError(pymsg) print msgs print pymsg