Skip to content

Instantly share code, notes, and snippets.

@nommuna2
Last active April 26, 2019 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nommuna2/fc11929f27e74dfbf1c123674f3bf94f to your computer and use it in GitHub Desktop.
Save nommuna2/fc11929f27e74dfbf1c123674f3bf94f to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Sample of adding an item to AGOL,publishing, overwriting, and updating
#Adding an item to AGOL and publishing it
csv = r'path to csv'
csvItem = gis.content.add({}, csv)
csvFeatureLayer = csvItem.publish()
#Overwriting a service
#Search for the FeatureService by name
MyFeatureService = gis.content.search(query='title:SampleTest AND owner:owner')
#Get the id related to the Feature Service
FeatureServiceID = layerID[0].id
#Call overwrite on the feature layer
myFeatureLayercollection = FeatureLayerCollection.fromitem(MyFeatureService)
myFeatureLayercollection.manager.overwrite(r'path tp csv')
#You can also update the csv item by using the update method
MyCSV = gis.content.search(query='title:Sample AND owner:owner') #Get the csvItem
#Grab the item from the array
item = MyCSV[0]
item.update({},r'path to csv')
@NicholeSalinger
Copy link

Thank you Muna!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment