Using arcpy.da.InsertCursor to insert entire row that is fetched from search cursor?
As long as your source and target FC's have the same number of fields and have the same geometry type, this should work:
# Get field objects from source FC
#
dsc = arcpy.Describe(sourceFC)
fields = dsc.fields
# List all field names except the OID field and geometry fields
# Replace 'Shape' with 'SHAPE@'
#
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]
# Create cursors and insert new rows
#
with arcpy.da.SearchCursor(sourceFC,fieldnames) as sCur:
with arcpy.da.InsertCursor(targetFC,fieldnames) as iCur:
for row in sCur:
iCur.insertRow(row)
Google suggested this answer for the following arcpy.da.InsertCursor error: "SystemError: error return without exception set"
The answer suggested here does not solve the issue if your are trying to use the da.InsertCursor to add data in a Geometric Network.
There is currently a bug (Bug NIM102778) on file with ESRI over this issue. The solution suggested by ESRI is to insert the data into an empty feature class then append the feature class to the geometric network.
That solution does work, however it's much slower. The older version of InsertCursor arcpy.InsertCursor()
will allow you to add data to a geometric network and maintain a decent level of performance.