Select to view content in your preferred language

Arcgis online service overwrite using python API

6833
6
09-22-2016 07:15 AM
unica360
Deactivated User

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!

6 Replies
JakeSkinner
Esri Esteemed Contributor

I believe this can be accomplished using ArcREST:

ArcREST/update_item.py at master · Esri/ArcREST · GitHub 

AndrewHargreaves
Deactivated User

The Attached Notebook Shows how ot do this exclusively in the Python API for ArcGIS.

by Anonymous User
Not applicable

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!

0 Kudos
DanielAragon1
Emerging Contributor

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! 

0 Kudos
MunachisoOgbuchiekwe
Regular Contributor

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).