UpdateCursor in a loop overwrites itself

637
1
03-01-2011 11:08 AM
roryosborne
New Contributor
Hi,
I'm trying to populate a dbase table with an update cursor. I have one loop for the first 2 columns, using an insertCursor, then I need to add further fields to the same table. The insert cursor works fine, but the update cursor overwrites itself on the first line every time. ideas?

if m == 0:
            rows = arcpy.InsertCursor(newTable)
            row = rows.newRow()
            row.DAUID = a
            row.setValue(fields, e)
            rows.insertRow(row)
               
elif m > 0:
            rows = arcpy.UpdateCursor(newTable)
            row = rows.next()
            row.setValue(fields, e)
            rows.updateRow(row)
Tags (2)
0 Kudos
1 Reply
BradPosthumus
Occasional Contributor II
From this code snippet it's not clear what you're trying to do here. You're adding a new record to the end of the table if you're using the first field in the list. If not, then what is it you're trying to update? Just the first record (as your code will do in each loop since you're re-creating the update cursor each time), or do you want to update all records including the new one added?

If you can provide more code or explain it better then it will be easier to troubleshoot.
0 Kudos