johans11

Conditional Update Fields

Discussion created by johans11 on Feb 14, 2012
Latest reply on Feb 15, 2012 by johans11
Hi Everyone,
I am trying to update a row (currently empty) based on the conditions of another field. Any help to my code or links to either useful help topics/tutorials would be welcomed. Here is my template so far....

try:
        rows =arcpy.UpdateCursor(r'C:\TempFolder\temp.shp')
        for row in rows:
            if row.GRIDCODE <= 1:
                row.MainClass = "Tropical/Megathermal"
                rows.updateRow(row) 
            if row.GRIDCODE >= 2 and row.GRIDCODE <= 5:
                row.MainClass = "Dry Climates"
                rows.updateRow(row) 
            if row.GRIDCODE >= 5 and row.GRIDCODE <= 10:
                row.MainClass = 2 #"Temperate/Mesothermal"
                rows.updateRow(row) 
            else:
                row.MainClass = "Continental/Microthermal"
        del row
        del rows


The code runs without a hitch however the row MainClass is not updated (basically im trying to classify numbers into a useful amalgamation of main names)

Thanks,
J

Outcomes