I need to write a script that deletes rows from one feature class and append data from another feature class to the first feature class. Both feature class has the same name but are stored in a different location, I need to run this script in the python window, I was wondering what could be the workaround to accomplish this task. The script needs to run in a Python window and other users need to run the script as well.
Here is an example below:
Feature Class A = Need to delete rows from this feature class.
Feature Class A = Append data from this feature class to the first feature class.
I hope this makes sense
Merge (Data Management)—ArcGIS Pro | Documentation if you want a new file
And regarding the same names: Use the full paths.
original_fc = "path:/to/the/fc_to_be_updated/FC_A" update_fc = "path:/to/the/update_fc/FC_A" arcpy.management.TruncateTable(original_fc) # deletes ALL rows! arcpy.management.Append(original_fc, update_fc) # for same table schema
Thank you, Johannes! this is working for me, but just a quick question, if I want to share this script with my colleague, how they are going to run it as I have assigned a path to my directories. I am just a beginner and still learning concepts of Python,
Again Thank you for your help!
If you are dealing with File Geodatabases (.gdb), they have to be in a location that is accessible to your colleagues.
If you're dealing with Enterprise Geodatabases (.sde), your colleagues have to connect as data owner to use TruncateTable. If they use their own connection files, they have to update the script with the right paths.
To run the script, your colleagues need ArcGIS installed on their PCs.
To share the script, you have a few options:
Thanks, Johannes, I am using the SDE version and I want to create a script tool, and in tool parameters, i will let users to input the data location paths. I am not sure how to give a path to sde version in parameters. the tutorials i found are all related to creating a new version could not find anything related to using the existing sde version in arcpy. One option I know is to go to the sde database connection properties and select geodatabase connection properties will allow you to change the whole sde connection database to the sde version, not sure if i should do that. Any advice from you would be greatly appreciated! and also i wanted to make that tool work for my colleagues too.