I need to transfer an entire layers features to another layer. I am trying to use the SearchCursor and InsertCursor to do this( I know I can use append, but I am trying to this way). Both Features have the same fields and same type of geometry, both are polygons.
in_features = "FeatureClass"
out_path = = "OtherFeatureClass"
dsc = arcpy.Describe(in_features)
fields = dsc.fields
# List all field names except the OID field
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName]
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#out_fields = [dsc.OIDFieldName]
#fieldnames = [fields.name for fields in fields if fields.name not in out_fields]
# Create cursors and insert new rows
#
with arcpy.da.SearchCursor(in_features,fieldnames) as sCur:
with arcpy.da.InsertCursor(out_path,fieldnames) as iCur:
for row in sCur:
iCur.insertRow(row)
del sCur
I get the following error.
iCur.insertRow(row)
RuntimeError: Number of parts in shape is incorrect for its geometry type