<?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 Betreff: Update CSV linked to Surveys via script in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524017#M58572</link>
    <description>&lt;P&gt;I'm not interested in the FME part, but if their connector can do what it claims it give me hope that what I want is indeed possible, I just need to find the correct REST endpoint.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 20:26:05 GMT</pubDate>
    <dc:creator>DuncanC</dc:creator>
    <dc:date>2024-08-19T20:26:05Z</dc:date>
    <item>
      <title>Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1523999#M58567</link>
      <description>&lt;P&gt;I want to automate the updating of the CSV files my surveys use.&amp;nbsp; But I cannot find a way to do the equivalent of pushing update data button in the online portal via script.&amp;nbsp; Using either the REST interface directly or the python SDK I can download the CSV, but I can't find a method to replace it with new data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could delete it, and upload a new copy, but that will have a new ID and I'm pretty certain it's not going to be linked to my surveys.&amp;nbsp; I've looked into adding a link to the new ID as linked content on the surveys via python, but that also looks to be a dead end and not available. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping I'm just missing something and there is a way to do this.&amp;nbsp; Any advice would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 19:16:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1523999#M58567</guid>
      <dc:creator>DuncanC</dc:creator>
      <dc:date>2024-08-19T19:16:19Z</dc:date>
    </item>
    <item>
      <title>Betreff: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524002#M58568</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/731197"&gt;@DuncanC&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my colleague is using FME Flow - maybe here is a good starting point:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-data-interoperability-blog/how-fme-flow-or-form-can-write-to-arcgis/ba-p/1218381" target="_blank"&gt;https://community.esri.com/t5/arcgis-data-interoperability-blog/how-fme-flow-or-form-can-write-to-arcgis/ba-p/1218381&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 19:33:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524002#M58568</guid>
      <dc:creator>HannesVogel</dc:creator>
      <dc:date>2024-08-19T19:33:32Z</dc:date>
    </item>
    <item>
      <title>Betreff: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524010#M58570</link>
      <description>&lt;P&gt;Thanks for the suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should have mentioned I'm using AGOL not a enterprise install so I don't think that solution works.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 19:52:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524010#M58570</guid>
      <dc:creator>DuncanC</dc:creator>
      <dc:date>2024-08-19T19:52:25Z</dc:date>
    </item>
    <item>
      <title>Betreff: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524013#M58571</link>
      <description>&lt;P&gt;if you have the FME possibility there is an AGOL connector as well:&amp;nbsp;&lt;A href="https://support.safe.com/hc/en-us/articles/25407563623565-How-to-use-the-EsriArcGISOnlineConnector" target="_blank"&gt;https://support.safe.com/hc/en-us/articles/25407563623565-How-to-use-the-EsriArcGISOnlineConnector&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 20:10:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524013#M58571</guid>
      <dc:creator>HannesVogel</dc:creator>
      <dc:date>2024-08-19T20:10:31Z</dc:date>
    </item>
    <item>
      <title>Betreff: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524017#M58572</link>
      <description>&lt;P&gt;I'm not interested in the FME part, but if their connector can do what it claims it give me hope that what I want is indeed possible, I just need to find the correct REST endpoint.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 20:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524017#M58572</guid>
      <dc:creator>DuncanC</dc:creator>
      <dc:date>2024-08-19T20:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524084#M58574</link>
      <description>&lt;P&gt;Hi Duncan,&lt;/P&gt;&lt;P&gt;I run a daily python script&amp;nbsp; to update a csv that I reference in one of my surveys in Survey123. I also only use AGOL not enterprise.&lt;/P&gt;&lt;P&gt;The steps I follow are:&lt;/P&gt;&lt;P&gt;1. re-create the csv locally &lt;STRONG&gt;exactly&lt;/STRONG&gt; how it is in AGOL so that you can use the update method on the csv in AGOL&lt;/P&gt;&lt;P&gt;2. run the following script&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; datetime&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; arcgis &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; GIS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; arcgis &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; features&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; arcgis.features &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; FeatureLayerCollection&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; datetime&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; sys&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# Connect to the GIS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;gis = &amp;nbsp;GIS(profile=&lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;) # Your profile name&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;token = gis._con.token&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# set variables and access json&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;portalUrl = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://www.arcgis.com" target="_blank" rel="noopener"&gt;https://www.arcgis.com&lt;/A&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;csvID = &lt;/SPAN&gt;&lt;SPAN&gt;""&amp;nbsp; # the id number of your csv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;csv_item_title = &lt;/SPAN&gt;&lt;SPAN&gt;"" # the title of your csv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;localfile = &lt;/SPAN&gt;&lt;SPAN&gt;"" # the local path to your file you wish to replace the csv with&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;currentdate = datetime.date.today()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# set log file for data logging&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;fp = open(&lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"a"&lt;/SPAN&gt;&lt;SPAN&gt;) # set up a log file as this is never a bad idea&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# Query to see if item exists&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print (&lt;/SPAN&gt;&lt;SPAN&gt;"...Searching for feature service..."&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;the_services = gis.content.search(query = &lt;/SPAN&gt;&lt;SPAN&gt;'title:'&lt;/SPAN&gt;&lt;SPAN&gt; + csv_item_title + &lt;/SPAN&gt;&lt;SPAN&gt;" AND "&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;'id:'&lt;/SPAN&gt;&lt;SPAN&gt; + csvID)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; len(the_services)!=&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; print(&lt;/SPAN&gt;&lt;SPAN&gt;"Couldn't find feature service"&lt;/SPAN&gt;&lt;SPAN&gt; + csv_item_title+ &lt;/SPAN&gt;&lt;SPAN&gt;" in AGOL. Exiting script"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; error_message = currentdate.strftime(&lt;/SPAN&gt;&lt;SPAN&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN&gt;)+&lt;/SPAN&gt;&lt;SPAN&gt;','&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;'csv not found\n'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; fp.write(error_message)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; fp.close()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print (&lt;/SPAN&gt;&lt;SPAN&gt;"....found feature service "&lt;/SPAN&gt;&lt;SPAN&gt; + csv_item_title+ &lt;/SPAN&gt;&lt;SPAN&gt;" in AGOL"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;#Update CSV Table in AGOL from local CSV file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;fs = gis.content.get(csvID)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; fs.update(data=localfile)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; print (&lt;/SPAN&gt;&lt;SPAN&gt;".....updating csv file in AGOL"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;except&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; error_message = currentdate.strftime(&lt;/SPAN&gt;&lt;SPAN&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN&gt;)+&lt;/SPAN&gt;&lt;SPAN&gt;','&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;'update in AGOL not successful\n'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; print (&lt;/SPAN&gt;&lt;SPAN&gt;"..error in updating csv file. Exiting script"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; fp.write(error_message)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; fp.close()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;# write the success to the log file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;message = currentdate.strftime(&lt;/SPAN&gt;&lt;SPAN&gt;"%Y/%m/%d"&lt;/SPAN&gt;&lt;SPAN&gt;)+&lt;/SPAN&gt;&lt;SPAN&gt;','&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;'Yes\n'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;fp.write(message)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;fp.close()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print(&lt;/SPAN&gt;&lt;SPAN&gt;"Script successful"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Aug 2024 21:50:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524084#M58574</guid>
      <dc:creator>AmeWunderle</dc:creator>
      <dc:date>2024-08-19T21:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Update CSV linked to Surveys via script</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524165#M58580</link>
      <description>&lt;P&gt;Thank you very much!!&amp;nbsp; Not sure how I missed that earlier today but your script helped me find the update method I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 02:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/update-csv-linked-to-surveys-via-script/m-p/1524165#M58580</guid>
      <dc:creator>DuncanC</dc:creator>
      <dc:date>2024-08-20T02:33:43Z</dc:date>
    </item>
  </channel>
</rss>

