I have a hosted table and I want to update it every day with new data (which includes old data). So what I need is to overwrite the entire hosted table exactly as I would clicking on AGOL item details interface "Update Data" > "Overwrite entire layer".
I tried:
gis = GIS("https://myorganization.maps.arcgis.com","user","pass")
# the hosted table item
table_ago = gis.content.get('xxxxxxxxxxxx')
#trying to update the item
table_ago.update({}, data=r'C:\\path\\table.csv')#it has the same name as the original csv from which the hosted table was published
[out] True # the output seems ok, but no updates on AGOL
# then try to republish
table_ago.publish(file_type='csv',overwrite=True)
[out] Traceback (most recent call last):
File "<ipython-input-112-378e1e03b9c6>", line 1, in <module>
table_ago.publish(file_type='csv',overwrite=True)
File "C:\conda\envs\covid-amazonas\lib\site-packages\arcgis\gis\__init__.py", line 11977, in publish
elif not buildInitialCache and ret[0]["type"].lower() == "image service":
KeyError: 'type'
Then I tried to do it using a Feature Collection:
gis = GIS("https://myorganization.maps.arcgis.com","user","pass")
# the hosted table item
table_ago = gis.content.get('xxxxxxxxxxxx')
# get it as a feature collection
table_ago_FC = FeatureLayerCollection.fromitem(table_ago)
# trying to update
table_ago_FC.manager.overwrite('C:\\path\\table.csv')
[out] Traceback (most recent call last):
File "<ipython-input-122-4098b20bab21>", line 1, in <module>
table_ago_FC.manager.overwrite('C:\\path\\table.csv')
File "C:\conda\envs\covid-amazonas\lib\site-packages\arcgis\features\managers.py", line 2036, in overwrite
if bool(self._fs.replicas.get_list()):
AttributeError: 'FeatureLayerCollection' object has no attribute 'replicas'
What is wrong? How can I do it?