How to append two FC one with additional fields in Python

06-01-2020 12:13 PM
Occasional Contributor III

Good afternoon,

I am writing a scripts that  appends records  in several FC and some of them have additional fields because the schema was  modified.

Can I use this kind of Python script with "NO_TEST"  when  I copy the same FC but the new version has more fields than the old one ?

taget_layer is the new version of source_layer but in several cases it has additional fields.

fieldmappings = arcpy.FieldMappings()

#Like when you manually choose a layer in the toolbox and it adds the fields to grid

arcpy.Append_management(append_laye, target_layer, 'NO_TEST', ffieldmappings)


0 Kudos
1 Reply
MVP Esteemed Contributor

from... Append—Data Management toolbox | Documentation 

clear ... I think

  • If Use the Field Map to reconcile schema differences is chosen (schema_type = "NO_TEST" in Python), the input dataset schema (field definitions) do not have to match the target dataset. However, any fields from the input datasets that do not match the fields of the target dataset will not be mapped to the target dataset unless the mapping is explicitly set in the Field Map parameter.

  • Because the input datasets' data is written to an existing target dataset that has a predefined schema (field definitions), the Field Map parameter does not allow for fields to be added or removed from the target dataset.

So I would give it a try on copies to confirm

... sort of retired...
0 Kudos