Select to view content in your preferred language

Update Cursor infinite loop

2030
10
Jump to solution
06-29-2012 10:09 AM
SusieGreen
Emerging Contributor
Hello everyone,

I am a python newbie and trying to update a field in a table based on a field in a feature class. The table already contains unique id's that have to match the id's in the feature class.
What happens with the code below is that it goes in an infinite loop where it writes just the first value from the feature class in all the table rows.
Any help would be greatly appreciated.

# write Value to Table         # search cursor         scurs = arcpy.SearchCursor(infc)         # update cursor         ucurs = arcpy.UpdateCursor(tbl)         for scur in scurs:             newRow = scur.getValue("ID")             while newRow <> 0:                 for ucur in ucurs:                     ucur.Value = scur.getValue("Value")                     # update row                     ucurs.updateRow(ucur)
Tags (2)
0 Kudos
10 Replies
PapantzinCid
Deactivated User
I was able to figure it out.  Thank you for taking the time to read. 
The problem was my update cursor:

geology = arcpy.UpdateCursor(Input_Geology_Feature_Class,["PTYPE", "Geology_Class"])

for updateRow in geology:
    if updateRow.PTYPE in dictionary:
        updateRow.Geology_Class = dictionary[updateRow.PTYPE]
        geology.updateRow(row)
del updateRow, geology
0 Kudos