<?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 Re: Update a CSV/hosted feature service in AGOL in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400410#M20100</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you ever come up with a solution to this?&amp;nbsp; I have the same problem.&amp;nbsp; I can get the csv to update if I delete it and upload it again, but this changes the id and then breaks the dashboard that is pointing to it.&amp;nbsp; I need to have the CSV update with current data that changes weekly and keep that dashboard up to date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Sep 2020 17:56:52 GMT</pubDate>
    <dc:creator>CynthiaKozma</dc:creator>
    <dc:date>2020-09-17T17:56:52Z</dc:date>
    <item>
      <title>Update a CSV/hosted feature service in AGOL</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400408#M20098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to upload a CSV to AGOL and then later on i have to update this file.&lt;BR /&gt;Publishing the file works. A hosted feature service is created.&lt;BR /&gt;But i have to update the file every day. Either a fully upload or an append will do the job. The id mustn't change, because the data is used in a dashboard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My script doesn't work. The update returns a 'TRUE' but the data isn't changed.&lt;/P&gt;&lt;P&gt;Any suggestions how i get the job done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;username = "username"&lt;BR /&gt;password = "pwd"&lt;BR /&gt;gis = GIS("https://www.arcgis.com", username, password)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;csv_file = 'd:\\file.csv'&lt;BR /&gt;csv_item = gis.content.add({}, csv_file)&lt;/P&gt;&lt;P&gt;csv_item.move('some_folder')&lt;/P&gt;&lt;P&gt;csv_lyr = csv_item.publish()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#&amp;nbsp;&amp;nbsp; -------- works up to here ---------&lt;/P&gt;&lt;P&gt;ret=csv_lyr.update(data='d:\\file_update.csv')&lt;/P&gt;&lt;P&gt;print (ret)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2020 11:55:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400408#M20098</guid>
      <dc:creator>gismoe</dc:creator>
      <dc:date>2020-04-20T11:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Update a CSV/hosted feature service in AGOL</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400409#M20099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a similar situation. I have a CSV-file-based 1-table feature-service; I want to script the process of refreshing that service via new CSV files (schema is same).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A &lt;STRONG&gt;truncate() and overwrite()&lt;/STRONG&gt; approach seems to work. However, I can't get a &lt;STRONG&gt;truncate() and append()&lt;/STRONG&gt; approach to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also need the option of &lt;STRONG&gt;just-appending&lt;/STRONG&gt;; this means there is no&lt;STRONG&gt; truncate()&lt;/STRONG&gt;, just appends to add new records. My code:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333399; font-family: terminal, monaco, monospace; font-size: 13px;"&gt;#Get Feature Service by Getting List of Item Objects via Query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Searching for feature service...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_services = gis.content.search(query = 'title:' + item_title + " AND " + 'id:' + item_id)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if len(the_services) != 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; print("Couldn't find feature service " + item_title + " in ArcGIS Online.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Get record count of feature service before update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Do this by getting "tables" property of the feature-service item;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#that property is a list of Table objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_tables = the_services[0].tables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if len(the_tables) != 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; print("Didn't find a 1-table feature-service as expected.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#(Capture table object.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;t = the_tables[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Before refresh, feature-service " + t.properties.name + " has " + str(t.query(return_count_only=True)) + " records.")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Truncate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Do this by getting the "manager" property of the Table object, "manager" being a FeatureLayerManager object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#from the arcgis.features.managers module; FeatureLayerManager has the truncate() method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Truncating...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_result = t.manager.truncate()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if the_result["success"] == False:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Something went wrong with the truncate.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Get and Update CSV Table in AGO&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Searching for CSV table in AGO...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_CSVs = gis.content.search(query = 'title:' + csv_item_title + " AND " + 'id:' + csv_item_id)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if len(the_CSVs) != 1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; print("Couldn't find CSV table " + item_title + " in ArcGIS Online.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;c = the_CSVs[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Update CSV Table in AGO from local CSV file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Updating CSV table in AGO...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_result = c.update(data = csv_path)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if the_result == False:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Something went wrong with updating CSV table.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Analyze CSV Table, to get a publishParameters object (from dictionary from analyze())&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Analyzing CSV table...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_analysis = gis.content.analyze(item = csv_item_id, file_type = "csv")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_publishParameters = the_analysis["publishParameters"]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#Append to Feature Service from CSV Table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#---&amp;gt; HERE'S THE PROBLEM, CAN'T GET append() TO WORK! SERVICE HAS 0 RECORDS AFTER THIS!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;print("Appending to feature service from CSV table...")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;the_result = t.append(item_id = csv_item_id, source_info = the_publishParameters, upload_format="csv")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;if the_result == False:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Something went wrong with the append.")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;#HOWEVER, THIS SEEMS TO WORK INSTEAD OF append()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace; color: #333399; font-size: 13px;"&gt;t.container.manager.overwrite(csv_path)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2020 14:48:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400409#M20099</guid>
      <dc:creator>IvanBrown</dc:creator>
      <dc:date>2020-04-20T14:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update a CSV/hosted feature service in AGOL</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400410#M20100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you ever come up with a solution to this?&amp;nbsp; I have the same problem.&amp;nbsp; I can get the csv to update if I delete it and upload it again, but this changes the id and then breaks the dashboard that is pointing to it.&amp;nbsp; I need to have the CSV update with current data that changes weekly and keep that dashboard up to date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2020 17:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400410#M20100</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2020-09-17T17:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Update a CSV/hosted feature service in AGOL</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400411#M20101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;what about updateing the feature service created from the csv file?&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/sample-notebooks/overwriting-feature-layers/" title="https://developers.arcgis.com/python/sample-notebooks/overwriting-feature-layers/"&gt;Overwriting feature layers | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2020 18:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400411#M20101</guid>
      <dc:creator>KarstenRank</dc:creator>
      <dc:date>2020-09-17T18:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Update a CSV/hosted feature service in AGOL</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400412#M20102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that might do it.&amp;nbsp; I think using the FeatureLayerCollection was the key.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #008000; font-weight: bold;"&gt;from&lt;/SPAN&gt; &lt;SPAN class="" style="color: #0000ff; font-weight: bold;"&gt;arcgis.features&lt;/SPAN&gt; &lt;SPAN class="" style="color: #008000; font-weight: bold;"&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;FeatureLayerCollection&lt;/SPAN&gt;&lt;SPAN class=""&gt;cities_flayer_collection&lt;/SPAN&gt; &lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;FeatureLayerCollection&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;fromitem&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cities_item&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;)
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;cities_flayer_collection&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;manager&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;overwrite&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;os&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;path&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;join&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;'data'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #ba2121;"&gt;'updating_gis_content'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;                               &lt;SPAN class="" style="color: #ba2121;"&gt;'updated_capitals_csv'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #ba2121;"&gt;'capitals_1.csv'&lt;/SPAN&gt;&lt;SPAN class=""&gt;))&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-csv-hosted-feature-service-in-agol/m-p/400412#M20102</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2021-12-11T18:16:54Z</dc:date>
    </item>
  </channel>
</rss>

