[GIS] ‘List indices must be integers not tuple’ Error

arcgis-10.2arcpypython

I'm using an insert cursor to write rows to a destination feature class where the input Shapefile field names do not match the destination FC names. To accomplish this, I'm trying to use the indices of the input shape field list to input to specific fields. Running into a "List indices must be integers not tuple" error when executing and have tried all combinations of brackets, parentheses, etc. I don't think I'm seeing the error right:

outfc = #the input shapefile from earlier in code
destsfp = #the destination featureclass from earlier in code

allrowvalues = arcpy.ListFields(outfc)
rowvalues = allrowvalues[[2],[3],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14]]
#open insert cursor
cursor = arcpy.da.InsertCursor(destsfp,('SHAPE@X','SHAPE@Y','SHAPE@Z','GRADIENT','BEARING','HEIGHT_IN_METRES','WIDTH_IN_METRES','LENGTH_IN_METRES','DEPRESSION_DEPTH','SYMBOLOGY','FEATURE_NAME','FEATURE_DESC'))
#insert new rows that have the above fields
for row in rowvalues:
    cursor.insertRow(row)
del cursor

Best Answer

based on all the comments, try something like this -

field_indexes_to_copy = [2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13 ,14]
search_cursor = arcpy.da.SearchCursor(outfc, "*")
insert_cursor = arcpy.da.InsertCursor(destsfp,('SHAPE@X','SHAPE@Y','SHAPE@Z','GRADIENT','BEARING','HEIGHT_IN_METRES','WIDTH_IN_METRES','LENGTH_IN_METRES','DEPRESSION_DEPTH','SYMBOLOGY','FEATURE_NAME','FEATURE_DESC'))

for row in search_cursor:
    insert_cursor.insertRow([row[i] for i in field_indexes_to_copy])

I haven't run this code myself, but I think that or something similar should work.