I have a feature class and python list. Feature class has 80 fields and 500 records. List also has 80 sub-list and 500 elements in each. So basically they are same dimension so to say.
I want to copy all records in python sub-list to corresponding fields in feature class. I was refering to an earlier post:
I tried the code below but it doesnot work. there is some logic error can anyone correct me.
fc = parameters.valueAsText # feature class selected from python toolbox fname = parameters.valueAsText #excel workbook selected from python toolbox. xl_workbook = xlrd.open_workbook(fname) sheet = xl_workbook.sheet_by_index(0) #here i am copying the excel sheet data to python list. l = [[sheet.cell_value(r,c) for r in range(sheet.nrows)] for c in range(sheet.ncols)] #sample of list : # l = [[u'OBJECTID', 1.0 , 2.0 , 3.0 , 4.0 ], [u'LENGTH', 56.29, 61.8 , 11.01 ,164.03]] #till here everything is working fine. #now i want to update the fields in feature class (fc) with the python list (l) i = 0 cursor = arcpy.UpdateCursor(fc) for row in cursor: row[i] = l[i] cursor.updateRow(row) #here i get 'valueError: Row: Invalid value for setting' i = i+1