<?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: need help overwriting hosted feature layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1006759#M5267</link>
    <description>&lt;P&gt;I export dataframe directly to a CSV that overwrites the file on AGOL every hour.&amp;nbsp; I couldn't get the dataframe to work and haven't had the time to suss out why but here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS('&amp;lt;AGOL ORG URL&amp;gt;', usernameAGOL, passy)
# #### 3.1.2 Update Parcel Action List

searchResult = gis.content.search(query="title:Parcel Action List")

pal = searchResult[1]

palTable = gis.content.get('&amp;lt;Insert item number here&amp;gt;')  #This gets the hosted table in AGOL
pal_collection = FeatureLayerCollection.fromitem(palTable)

pal_collection.manager.overwrite(newCSV)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where newCSV is the CSV I exported from my pandas frame and is stored in a folder every hour.&amp;nbsp; Every hour, it finds the CSV, renames it to "CSV_OLD" in case something goes wrong, and then recreates a new CSV from the data with the same name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited to include gis variable in python&lt;/P&gt;&lt;P&gt;I'm not versed enough to be able to get the token stuff working yet - so I explicitly state the username &amp;amp; password in this script, although you should probably at least create a secrets file if you know how&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 20:01:15 GMT</pubDate>
    <dc:creator>Kara_Shindle</dc:creator>
    <dc:date>2020-12-03T20:01:15Z</dc:date>
    <item>
      <title>need help overwriting hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1004675#M5242</link>
      <description>&lt;DIV class="cell border-box-sizing text_cell rendered"&gt;&lt;DIV class="prompt input_prompt"&gt;According to the example below, you can use FeatureCollection. manager.overwrite to wholesale overwrite a feature layer you have hosted on AGOL -- or perhaps this is only an option for the Enterprisers?&amp;nbsp; But, the example is built in terms of csv's stored locally on one's own hard drive.&amp;nbsp; I have a spatial dataframe that I am pushing directly to AGOL without making any local shapefile or anything (sdf.spatial.to_featurelayer).&lt;/DIV&gt;&lt;DIV class="prompt input_prompt"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="prompt input_prompt"&gt;As I am regularly updating the sdf, I'd like to overwrite the hosted feature layer directly and often.&amp;nbsp; Can that be done?&amp;nbsp; The docs say, "Only hosted feature layer collection services can be overwritten" and I get about as far as "hosted feature layer . . . " before I don't know what that phrase means.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="inner_cell"&gt;&lt;DIV class="text_cell_render border-box-sizing rendered_html"&gt;&lt;H2&gt;Overwrite the feature layer&lt;/H2&gt;&lt;P&gt;Let us overwrite the feature layer using the new csv file we just created. To overwrite, we will use the overwrite() method.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="cell border-box-sizing code_cell rendered"&gt;&lt;DIV class="input"&gt;&lt;DIV class="prompt input_prompt"&gt;In&amp;nbsp;[21]:&lt;/DIV&gt;&lt;DIV class="inner_cell"&gt;&lt;DIV class="input_area"&gt;&lt;DIV class="highlight hl-ipython3"&gt;&lt;PRE&gt;&lt;SPAN class="kn"&gt;from&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcgis.features&lt;/SPAN&gt; &lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="n"&gt;FeatureLayerCollection&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;cities_flayer_collection&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;FeatureLayerCollection&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fromitem&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;cities_item&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="cell border-box-sizing code_cell rendered"&gt;&lt;DIV class="input"&gt;&lt;DIV class="prompt input_prompt"&gt;In&amp;nbsp;[22]:&lt;/DIV&gt;&lt;DIV class="inner_cell"&gt;&lt;DIV class="input_area"&gt;&lt;DIV class="highlight hl-ipython3"&gt;&lt;PRE&gt;&lt;SPAN class="c1"&gt;#call the overwrite() method which can be accessed using the manager property&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;cities_flayer_collection&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;manager&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;overwrite&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;os&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;path&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;join&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'data'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'updating_gis_content'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;
                               &lt;SPAN class="s1"&gt;'updated_capitals_csv'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'capitals_1.csv'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;))&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 Nov 2020 15:51:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1004675#M5242</guid>
      <dc:creator>JillRKelly</dc:creator>
      <dc:date>2020-11-25T15:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: need help overwriting hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1006759#M5267</link>
      <description>&lt;P&gt;I export dataframe directly to a CSV that overwrites the file on AGOL every hour.&amp;nbsp; I couldn't get the dataframe to work and haven't had the time to suss out why but here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS('&amp;lt;AGOL ORG URL&amp;gt;', usernameAGOL, passy)
# #### 3.1.2 Update Parcel Action List

searchResult = gis.content.search(query="title:Parcel Action List")

pal = searchResult[1]

palTable = gis.content.get('&amp;lt;Insert item number here&amp;gt;')  #This gets the hosted table in AGOL
pal_collection = FeatureLayerCollection.fromitem(palTable)

pal_collection.manager.overwrite(newCSV)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where newCSV is the CSV I exported from my pandas frame and is stored in a folder every hour.&amp;nbsp; Every hour, it finds the CSV, renames it to "CSV_OLD" in case something goes wrong, and then recreates a new CSV from the data with the same name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited to include gis variable in python&lt;/P&gt;&lt;P&gt;I'm not versed enough to be able to get the token stuff working yet - so I explicitly state the username &amp;amp; password in this script, although you should probably at least create a secrets file if you know how&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 20:01:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1006759#M5267</guid>
      <dc:creator>Kara_Shindle</dc:creator>
      <dc:date>2020-12-03T20:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: need help overwriting hosted feature layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1375739#M9594</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 23:08:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/need-help-overwriting-hosted-feature-layer/m-p/1375739#M9594</guid>
      <dc:creator>LoganLaudano</dc:creator>
      <dc:date>2024-01-29T23:08:47Z</dc:date>
    </item>
  </channel>
</rss>

