I'm pretty new to the ArcGIS API for Python. I'm trying to use the Append function to append data from a source file geodatabase that is hosted on AGO to a target feature layer. I'm using the upsert parameter because, not only am I adding additional features to the target from the source, but I've also changed some of the attributes within the source and I want those changes reflected in the target.
What I'm trying to do is pretty basic I think, but when I run my script I get the message "append() takes no keyword arguments".
Here's my code:
import os
from arcgis.gis import GIS
# Create a GIS connection to AGO where the test data is located
gis = GIS(url, username, password)
# Target feature layer (feature layer with fewer points that needs to be updated)
target_item = gis.content.get("1fbf6a4e1ebe4720aa7036a3d52f7544")
print("feature layer to update:", target_item)
target_lyr = target_item.layers
# Look for the unique field within the target layer
# simply verifies that I had a field with unique values in my target layer
"""
uk_flds = (f.fields for f in target_lyr[0].properties.indexes if f.isUnique)
for fld in target_lyr[0].properties.fields:
if fld.name in uk_flds:
print(f"{fld.name:30}{fld.type:25}isUnique")
else:
print(f"{fld.name:30}{fld.type:25}")
"""
# Source fgdb
src_lyr = gis.content.search("Water_system_valves_source")[0]
print(src_lyr)
# Run the Append function
target_lyr.append(
source_table_name="test",
item_id=src_lyr.id,
upload_format="filegdb",
upsert=True,
skip_updates=False,
use_globalids=False,
update_geometry=True,
append_fields=["FID", "VALVETYPE", "Creator"],
rollback=False,
skip_inserts=False,
upsert_matching_field="FID",
)
The field with unique values that matches records between the two layers is "FID." I specified "FID", "VALVETYPE", and "Creator" in the append_fields parameter because VALVETYPE and Creator are the two fields where attribute values were changed in the source dataset. FID was specified because it is the unique identifier (I'm not sure if this is correct, but it's what I took away from some of the documentation). All of the fields are the same between the source and target layers, but they're in a slightly different order.
I primarily followed this resource: https://developers.arcgis.com/python/guide/appending-features/ (starting at the "Insert New Features and Update Existing Features - Upsert" section).
Any assistance would be appreciated. Thank you.