We have 60 - 70 footprints for which the attributes are to be updated for 25 columns. Some of the columns will have coded values (Eg: Country, Metadata standard, Language). I've slightly modified the code provided in this thread Using UpdateCursor for joined field in ArcPy? (Second one - Code provided by Emil Brundage ). Since i don't know how to make the fields to be read in loop, for 25 fields i've used the same code. As an example i've only listed three fields.
Every column in the footprint is getting updated with the values from an excel sheet w.r.t "Name"column in both footprint & excel sheet. But "Language"column has not been updated and all i am getting is ""Create cursor has failed". "Language""column has coded values (English, Spanish, Portugese etc..). But the other columns with coded values are getting updated without any issues. Any suggestions on how to sort this out ?
import arcpy
footprint = arcpy.GetParameterAsText(0)
footprintFld1 = "Title"
footprintFld2 = "Date"
footprintFld3 = "Language"
footprintIdFld = arcpy.GetParameterAsText(1)
excel = arcpy.GetParameterAsText(2)
excelFld1 = "Title"
excelFld2 = "Date"
excelFld3 = "Language"
excelIdFld = arcpy.GetParameterAsText(3)
valueDi = dict ([(key, val) for key, val in arcpy.da.SearchCursor (excel, [excelIdFld, excelFld1])])
with arcpy.da.UpdateCursor (footprint, [footprintFld1, footprintIdFld]) as cursor:
for update, key in cursor:
if not key in valueDi:
continue
row = (valueDi [key], key)
cursor.updateRow(row)
del cursor
valueDi = dict ([(key, val) for key, val in arcpy.da.SearchCursor (excel, [excelIdFld, excelFld2])])
with arcpy.da.UpdateCursor (footprint, [footprintFld2, footprintIdFld]) as cursor:
for update, key in cursor:
if not key in valueDi:
continue
row = (valueDi [key], key)
cursor.updateRow(row)
del cursor
valueDi = dict ([(key, val) for key, val in arcpy.da.SearchCursor (excel, [excelIdFld, excelFld3])])
with arcpy.da.UpdateCursor (footprint, [footprintFld3, footprintIdFld]) as cursor:
for update, key in cursor:
if not key in valueDi:
continue
row = (valueDi [key], key)
cursor.updateRow(row)
del cursor
...
Runtime error
Traceback (most recent call last):
File "<string>", line 35, in <module>
RuntimeError: create cursor has failed
>>>
35th line in the code is // valueDi = dict ([(key, val) for key, val in arcpy.da.SearchCursor (excel, [excelIdFld, excelFld3])]) //. And, i am running this script as a tool from ArcToolbox.