Errors when publishing more than one CSV to AGOL

125
0
05-03-2021 01:28 PM
ChrisPeak
New Contributor

I'm trying to publish multiple CSV's as hosted tables in ArcGIS Online, using the Python API version 1.7.1.   Python version is 3.7.10.   

My code works for the first layer I add and publish, but any subsequent CSV's produce an error:

File "<stdin>", line 1, in <module>
File "my_directory\Continuum\anaconda3\lib\site-packages\arcgis\gis\__init__.py", line 9029, in publish
elif not buildInitialCache and ret[0]['type'].lower() == 'image service':
KeyError: 'type'

 

This works:

 

from arcgis.gis import GIS
gis = GIS(my_organizations_AGOL_portal, my_username, my_pw)
exported = gis.content.add(
   {'title': 'test_csv1', 'tags':'test', 'description':'some desc'}, 
   data='csv1.csv')
pub_csv = exported.publish(publish_parameters={"type":"csv","locationType":"none"})

 

 

When I try to export and publish a second CSV, as in the following, I get the error on the last line:

 

exported = gis.content.add({'title': 'test_csv2', 'tags':'test', 'description':'some desc'}, data='csv2.csv')
pub_csv = exported.publish(publish_parameters={"type":"csv","locationType":"none"})

 

 

The two CSV files are copies of the same file so I know this isn't an issue with the CSV itself.  And if I reverse the order of the files, the first in my batch always succeeds and the second fails.  

If I delete the first CSV then the second one can successfully be published.

Any help is appreciated!

0 Kudos
0 Replies