dellis78

Problem with Update Cursor

Discussion created by dellis78 on Sep 19, 2011
Latest reply on Oct 7, 2011 by stacyrendall
Hi,
Im new to Python and have been trying to teach myself.
I am trying to calculate fields based on the results of two fields and read that using an update cursor is the best way to do this. I have attemped to create one but it still doesn't work, its not returning any errors but its doens't return any results.

Help!!

#--------------------------------
import os
import sys
import arcpy
import arcgisscripting
import functools
import arcpy.geoprocessing

def updateCursor(str):
    """Update fields based on analyis"""
    try:
        arcpy.gp._base._updateCursor = True
        arcpy.env.overwriteOutput = True
        arcpy.env.workspace = "C:\Temp\BAL_Mapping.gdb"

        # Create Update Cursor for feature Class
        rows = arcpy.gp._base._updateCursor ("C:\Temp\BAL_Mapping.gdb\INTERFACE")
        rows = row.next ()
        while row:
            if row.Slope == "0-5" and row.Veg == "Woodland":
                row.BALFZ = "15"
            elif row.Slope == "0-5" and row.Veg == "Forest":
                row.BALFZ = "24"
            else:
                row.BALFZ = "0"
            rows.row (row)
            row = row.next ()

        pass
    except arcpy.ExecuteError:
        print arcpy.GetMessages(2)
    except Exception as e:
        print e.args[0]

# End updateCursor function

if __name__ == '__main__':
    argv = tuple(arcpy.GetParameterAsText(i)
            for i in range(arcpy.GetArgumentCount()))
    updateCursor(str)

Outcomes