Append_management Not Honoring Selected Features

544
3
05-15-2019 07:44 AM
JCann
by
New Contributor II

I have been trying to write a simple script to append features (currently using ArcMap 10.6) that were created in a "working" file gdb to a "master" file gdb. The feature classes have the same fields and are both in feature data-sets. The "master" generally resides on an office wide server while "working" is local. Where it goes wrong is the stand alone script copies all features in the feature class, not just the selected features. Append honors selected features when run from python in ArcMap and from the GUI tool. Also experiencing the same issue if I create an append model. 

What I have tried: "NO_TEST" and "TEST", setting the "working" gdb as the work-space, placing the file pathways directly into Append_management, placing a copy of the "master" onto my computer. I have even tried creating temp gdbs, one with the "working" feature class and one with the "master" with no change. 

Going to test this on a different computer that has ArcMap 10.7 and in ArcGIS Pro 2.3 (can't use this computer at work though) and see if I can replicate it.

import arcpy

in_feature = r"C:\\\\Working_GDBs\Central.gdb\Lands\Disposals"
out_feature = r"C:\\\\Master_GDBs\Central.gdb\Lands_Master\Lands_Disposals"

schema = "TEST"

arcpy.Append_management(in_feature, out_feature, schema, " ", " ")

print("Append Completed")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
3 Replies
KenHartling
Esri Contributor

Is this a stand alone script run outside of the ArcGIS UI's?

If so... your script has no selection so it will append everything.

In the script you will need to create a layer based on the in_layer, make a selection (SelectLayerByAttribute, SelectLayerByLocation, etc) and then run Append.

JCann
by
New Contributor II

Thanks. I am new to python and that is not entirely clear in the documentation for Append_management, or at least not to me. This gives me a starting point at least and it also means that this may not work for what I need it to do. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

As a suggestion I would drop the last two optional parameters.  Unless it was a copy/past issue, you used " ", instead of "" (ie there should be no space in the method.  It is often safer to used named parameters rather than relying on fixed variables

arcpy.Append_management(in_feature, out_feature, schema)‍‍
# or
arcpy.Append_management(in_feature, out_feature, schema_type="TEST")‍‍
0 Kudos