<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Errors when publishing more than one CSV to AGOL in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/errors-when-publishing-more-than-one-csv-to-agol/m-p/1053972#M61008</link>
    <description>&lt;P&gt;I'm trying to publish multiple CSV's as hosted tables in ArcGIS Online, using the Python API version 1.7.1.&amp;nbsp; &amp;nbsp;Python version is 3.7.10.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;My code works for the first layer I add and publish, but any subsequent CSV's produce an error:&lt;/P&gt;&lt;P&gt;&lt;!-- StartFragment  --&gt;&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "my_directory\Continuum\anaconda3\lib\site-packages\arcgis\gis\__init__.py", line 9029, in publish&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;elif not buildInitialCache and ret[0]['type'].lower() == 'image service':&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;KeyError: 'type'&lt;/STRONG&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to export and publish a second CSV, as in the following, I get the error on the last line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two CSV files are copies of the same file so I know this isn't an issue with the CSV itself.&amp;nbsp; And if I reverse the order of the files, the first in my batch always succeeds and the second fails.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I delete the first CSV then the second one can successfully be published.&lt;/P&gt;&lt;P&gt;Any help is appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 20:28:33 GMT</pubDate>
    <dc:creator>ChrisPeak</dc:creator>
    <dc:date>2021-05-03T20:28:33Z</dc:date>
    <item>
      <title>Errors when publishing more than one CSV to AGOL</title>
      <link>https://community.esri.com/t5/python-questions/errors-when-publishing-more-than-one-csv-to-agol/m-p/1053972#M61008</link>
      <description>&lt;P&gt;I'm trying to publish multiple CSV's as hosted tables in ArcGIS Online, using the Python API version 1.7.1.&amp;nbsp; &amp;nbsp;Python version is 3.7.10.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;My code works for the first layer I add and publish, but any subsequent CSV's produce an error:&lt;/P&gt;&lt;P&gt;&lt;!-- StartFragment  --&gt;&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "my_directory\Continuum\anaconda3\lib\site-packages\arcgis\gis\__init__.py", line 9029, in publish&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;elif not buildInitialCache and ret[0]['type'].lower() == 'image service':&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;KeyError: 'type'&lt;/STRONG&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to export and publish a second CSV, as in the following, I get the error on the last line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two CSV files are copies of the same file so I know this isn't an issue with the CSV itself.&amp;nbsp; And if I reverse the order of the files, the first in my batch always succeeds and the second fails.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I delete the first CSV then the second one can successfully be published.&lt;/P&gt;&lt;P&gt;Any help is appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 20:28:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/errors-when-publishing-more-than-one-csv-to-agol/m-p/1053972#M61008</guid>
      <dc:creator>ChrisPeak</dc:creator>
      <dc:date>2021-05-03T20:28:33Z</dc:date>
    </item>
  </channel>
</rss>

