There are two tables of different feature class, say Source
and Target
, the fields in both the table are not same and even the number of fields are different.
There are 5 different fields that need to be copied from Source
to Target
(name of each field is different)
Field names are, -UUID
in Source
table which is similar to NE_UUID
in Target
table
date_of_Modification
in Source
table which is similar to NE_date_of_modification
in Target
table
and so on for rest of 3 fields.
The catch is, if UUID
(source) is not present in NE_UUID
(target) it should insert the entire row of 5 fields to target table.
Is there a function/method in arcpy which can do this, or do I need to use cursor for the same?
After some research, I found a way.
curS2=arcpy.da.SearchCursor(target,"NE_UUID")
curS3=arcpy.da.SearchCursor(source,source_list)
curI=arcpy.da.InsertCursor(target, target_list)
curS_list=[y[0] for y in curS2]
print ("loading list.....")
for x in curS3:
if not x[0] in curS_list:
curI.insertRow(x)
del curI,curS2,curS3