I need to insert missing features from one layer to another. I don't want to use the append tool because I don't want a new dataset, I just want to insert the missing features. Both are polygons and have pretty much the same fields except for 3 fields ('Field1','Field2', 'Field3'). I have the following but I get no error when I run it.
import arcpy
fc1 = "lyTB"
targetFC = "lyA_2"
dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
keepList = []
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
for row in cursor:
keepList.append(row[0])
#print(keepList)
del cursor
#list of values from fc1 to inject into targetFC
ids = []
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
for row in cursor:
#print (row)
if row[0] not in keepList:
ids.append(row)
del cursor
#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
for rows in ids:
insertCursor.insertRow(rows)
print ('Done')