I've written a python script (ArcGIS 10.0) for importing point objects from Excel sheets to our ArcSDE database. This works fine, but I'd like to make this script a bit more custamizable by the user and therefore want to use a python list for updating my data. I've tried the following, but unfortunately the update cursor does not work together with a python list and I'm getting the error "Field item does not exist".
import os, arcpyfc = r"C:\temp\temp.gdb\tempFC"rowlist = [("NAME", "Testname"),("COMMENT", "Testcomment")]print "Normal UpdateCursor"fcCursor = arcpy.UpdateCursor(fc)for row in fcCursor: row.NAME = "test 1" row.COMMENT = "test 1" fcCursor.updateRow(row)del rowdel fcCursorprint "Finished"print "UpdateCursor with python list"fcCursor = arcpy.UpdateCursor(fc)for row in fcCursor: for item in rowlist: row.item[0] = item[1] fcCursor.updateRow(row)del rowdel fcCursorprint "Finished"I've also tried
variable = "row.%s = %s" % (item[0], item[1])variableinstead of
row.item[0] = item[1]I'm not getting an error anymore, but nothing will be updated then...Anyone another idea how to make this work?
Thanks in advance!Beate
أكثر...
import os, arcpyfc = r"C:\temp\temp.gdb\tempFC"rowlist = [("NAME", "Testname"),("COMMENT", "Testcomment")]print "Normal UpdateCursor"fcCursor = arcpy.UpdateCursor(fc)for row in fcCursor: row.NAME = "test 1" row.COMMENT = "test 1" fcCursor.updateRow(row)del rowdel fcCursorprint "Finished"print "UpdateCursor with python list"fcCursor = arcpy.UpdateCursor(fc)for row in fcCursor: for item in rowlist: row.item[0] = item[1] fcCursor.updateRow(row)del rowdel fcCursorprint "Finished"I've also tried
variable = "row.%s = %s" % (item[0], item[1])variableinstead of
row.item[0] = item[1]I'm not getting an error anymore, but nothing will be updated then...Anyone another idea how to make this work?
Thanks in advance!Beate
أكثر...