Hi, we frequently use de 'overwrite' function in AGOL interface in order to update a feature service content, based on a .shp or .csv original file.
We now would need to perform this same function using the Arcgis API for python. Can you please specify what modules, classes functions are needed. A sample code would be greta.
Please note we need to update / overwrite from a file (shape, csv) not a .mxd or geodatase.
Thanks a lot in advanced!
I believe this can be accomplished using ArcREST:
Hey Andrew (great name, btw)!
Will your sample work for .MXDs as well? Currently my script is a good bit more 'complex' (i.e. a good bit longer), but if I could simplify my code by using the provided sample as is (or with slight modification), it'd make everyone happier!
If it needs to be modified, would you mind pointing me in the right direction? Thanks!
Thanks for the Python API for ArcGIS solution. However, I still can't figure out if there's a way to overwrite a csv on AGOL. I found a method for overwriting a feature layer, but not a csv. Any help is much appreciated!
Hello Daniel,
You can use the update method on an item to overwrite a csv on AGOL. Something like this might work for you.....
import arcgis
from arcgis.gis import GIS
gis = GIS()
# Grab the id of the csv
csv = gis.content.get('ef220b9f500348e5867095d10fe751e5')
# Call the update method to replace/overwrite it with a csv file from disk
csv.update({}, r'path to csv file from disk')
You can read up more on the parameters of the update method on the API documentation page (arcgis.gis module — arcgis 1.5.0 documentation).