AnsweredAssumed Answered

sequence size must match size of the row

Question asked by jaygis on Oct 15, 2020
Latest reply on Oct 19, 2020 by jaygis

Hi, I am looking for some help on proper syntax in ArcGIS Pro/ Python 3. I am trying to read data from a feature class and write to another feature class. The attribute fields are different so I am reading from source and assigning it to output. I get this error at insertCursor.insertRow(newRow).

 

Appreciate any input.
Thanks

 

 

 

def LoadData(fSource, fTarget):
# setup search cursor
fields = ['*']  fldShape = "SHAPE@"# target field mapping fldCountry = 'Country'fldCommodity = "Product"constructionYear = "CNSTR_YEAR"try:      with arcpy.da.InsertCursor(fTarget, ['*']) as insertCursor:         with arcpy.da.SearchCursor(fSource, "*") as cursor:             for row in cursor:                 country = row[cursor.fields.index(fldCountry)]                 geometry = row[cursor.fields.index(fldShape)]                 commodity = row[cursor.fields.index(fldCommodity)]                 constructionYear = row[cursor.fields.index(constructionYear)]                                  newRow = [country, geometry, commodity, constructionYear]                  insertCursor.insertRow(newRow)  except Exception:         print(e.args[0])

Outcomes