Overwrite Hosted Table

609
2
04-01-2020 06:43 AM
BrianKaplan
Occasional Contributor

Hi,  I'm having trouble overwriting a hosted table using the python api in Jupyter Notebooks.

I've logged in to the organizational account in the script where I'm an administrator and here is the rest of the code

oldcsv = gis.content.get('ecc751eadabe43c083360c07bb7cghbc')

oldcsvFLC = FeatureLayerCollection.fromitem(oldcsv)

oldcsvFLC.manager.overwrite(r'C:\path\out4.csv')

And the response below.  This test was done on 40 records but I eventually want to use a dataset with >100,000

Any guidance or suggestions would be most welcome.  I simply want to update the hosted table which would be joined to a feature class of admin boundaries.  
Thanks
Brian
---------------------------------------------------------------------------Exception                                 Traceback (most recent call last)<ipython-input-51-7974c8cc0fe0> in <module>----> 1 oldcsvFLC.manager.overwrite(r'C:\path\out4.csv')~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone1\lib\site-packages\arcgis\features\managers.py in overwrite(self, data_file)   1324         #region Perform overwriting   1325         if related_data_item.update(item_properties=params, data=data_file):-> 1326             published_item = related_data_item.publish(publish_parameters, overwrite=True)   1327             if published_item is not None:   1328                 return {'success': True}~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone1\lib\site-packages\arcgis\gis\__init__.py in publish(self, publish_parameters, address_fields, output_type, overwrite, file_type, build_initial_cache)   9030             return Item(self._gis, ret[0]['serviceItemId'])   9031         else:-> 9032             serviceitem_id = self._check_publish_status(ret, folder)   9033         return Item(self._gis, serviceitem_id)   9034  ~\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone1\lib\site-packages\arcgis\gis\__init__.py in _check_publish_status(self, ret, folder)   9257                     #print(str(job_response))   9258                     if job_response.get("status") in ("esriJobFailed","failed"):-> 9259                         raise Exception("Job failed.")   9260                     elif job_response.get("status") == "esriJobCancelled":   9261                         raise Exception("Job cancelled.")Exception: Job failed. 
0 Kudos
2 Replies
BrianKaplan2
Occasional Contributor

I found a solution.  If you add the csv file to AGOL without publishing it then publish it (in my case as a table without geocoding), the overwrite method works (oldcsvFLC.manager.overwrite(r'C:\path\out4.csv').    It is when I publish the table from ArcGIS Pro (presumably ArcMap too) that the overwrite method doesn't work.  I suspect it has something to do with a service definition file which I do not see if I publish from within AGOL.

ConradSchaefer__DOIT_
New Contributor II

Brian,

Encountering the same issue as you: Job Failed. But not finding your solution to be a fix.

I never published from ArcPro but encountered the issue. I uploaded a non-spatial csv to ArcGIS Online. Then published it as a hosted table in a separate step. I wanted to update the data in that hosted table.

The FeatureLayerCollection.manager.overwrite method is resulting in failed job. I ensure the file name was identical to the one originally used (which is a very strange requirement). The file schema is identical to original since the same process generated the original and my update file. 

I can do so with the arcgis.features.Table delete and add features methods. But, there is a note that if you are working with more than 250 features the append method should be used. Problem is the append method is not working and seems to be a sticking point for many. Was examining this as an alternative.

just adding this info in case someone else comes along with same issue.

Thanks

 

0 Kudos