UpdateCursor changes not appearing in FC attribute table

Discussion created by leftieant76 on Sep 17, 2012
Latest reply on Sep 17, 2012 by leftieant76
Gday all

I am trying to write a script to assist in attributing a dataset I am creating.

The dataset consists of polygons with the attribute of SECTION and SUBSECTION. Section will refer to a group of individual features (anywhere from 1 to 25+ features) and SUBSECTION refers to the individual number of that feature within the section.

I have written a script to iterate through the dataset, section by section, and write the subsection number to the correct field. The script executes correctly, and I have written in a line to check that the value has actually been written to the record - which it appears to.

However once the script is completed, and I view the FC in either ArcMap or ArcCatalog, the values do not appear in the attribute table.

I cannot for the life of me work out why. Can anyone assist?

Code attached:

# Author: ac0t
# Date: 17 Sep 2012
# Purpose: Iterate through Burn Unit data. Apply consecutive numbers to subsection field for each section

import arcpy
from arcpy import env

arcpy.env.workspace = r"U:\Burn Units\20120516_MUR.gdb\BurnUnits_FINAL_gda94"

section = 1

while section < 248: #loops thru all 247 sections
    print "Section Number: " + str(section)
    query = "\"SEC_NUMBER\" = " + str(section) # could be a problem with the query being formed
    cur = arcpy.UpdateCursor("BurnUnits_subsection_aggregated", query) #create UpdateCursor on only records with correct Section number
    subsection = 1
    for row in cur: # iterates thru features with section number, writes consecutive subsection number starting at 1
        print "Section Number (from Update Cursor): " + str(row.getValue("SEC_NUMBER"))
        print "Subsection Number: " + str(subsection)
        #row.setValue("SUBSECTION", subsection) #changed this line
        row.SUBSECTION = int(subsection)
        subsection = subsection + 1
        print "Subsection Number (from Update Cursor: " + str(row.getValue("SUBSECTION"))
    del row, cur, subsection
    section = section + 1

del section