Publish CSV to Enterprise Portal Errors

4438
13
Jump to solution
03-10-2021 09:32 AM
JaredPilbeam2
MVP Regular Contributor

I'm trying to do something simple using the following help doc, but I can not seem to publish.
https://geosaurus.maps.arcgis.com/home/item.html?id=a1db6db172bc49a8932daacc2ed3d3ac#preview

I'm able to add it to the Portal, but I cannot get it to publish.

from IPython.display import display
from arcgis.gis import GIS
import os
gis = GIS('Home')

csv_file = r'C:\Users\jpilbeam\Downloads\c19_Vaccine_Current.csv'
csv_item = gis.content.add({}, csv_file)#add csv to Portal

csv_layer = csv_item.publish(None, file_type='csv')

 

Error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
In  [15]:
Line 1:     csv_layer = csv_item.publish(None, file_type='csv')

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py, in publish:
Line 10353: elif not buildInitialCache and ret[0]['type'].lower() == 'image service':

KeyError: 'type'
---------------------------------------------------------------------------

 

Other attempts:

csv_layer = csv_item.publish()

Error:
KeyError: 'type'

 

csv_layer = csv_item.publish('csv')

Error:
ValueError: dictionary update sequence element #0 has length 1; 2 is required

 

 

0 Kudos
13 Replies
MehdiPira1
Esri Contributor

@JaredPilbeam2 ,

Found the problem. The catch here is specifying none for the location type since there is no coordinates in the csv file and I didn't know publishing a csv in Portal would require some parameters (type and location type) to specify in this case, compared to publishing to AGOL which you can (also) publish without parameters.

 

params={"type":"csv","locationType":"none"}
csv_item.publish(publish_parameters=params)

 

 Make sure you first delete the defective published csv feature layer.

Cheers

Mehdi

 

0 Kudos
JaredPilbeam2
MVP Regular Contributor

@MehdiPira1 

Thanks, I was able to publish a blank CSV with those parameters! But, I'm still getting a KeyError with the CSV I actually need published. I've continued the conversation in my other post where I attached the troublesome CSV. Thanks for your help.

0 Kudos
MarcusAndersson
New Contributor III

Hi,

I found this post quite randomly, but just wanted to let you know that the name of the Portal, your Username, and your Password is written in plain text in your post. I would suggest to edit and remove this asap.

BR,
Marcus

MehdiPira1
Esri Contributor

@JaredPilbeam2 

Not a problem.

0 Kudos