<?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 FeatureLayerCollectionManager.overwrite crashes a layer in Portal in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollectionmanager-overwrite-crashes-a/m-p/1075489#M6315</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have a workflow that uses an export from a FileMaker-database, preprocesses it, and then "updates" (overwrites) a layer in a feature layer collection. The script below runs fine, until it doesn't! It usually runs for some 2-3 days before something fails during the publishing phase. This is scheduled through a *.bat-file to run once every hour, but once it has failed, the layer becomes empty and it's not possible to "repair" in any way.&lt;BR /&gt;The only way is to republish the data from zero, which then of course creates a new item-ID etc. Alas, this is not a viable solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Import used libraries
import pandas as pd
from arcgis.gis import GIS
from arcgis import features
from arcgis.features import FeatureLayerCollection

# Preprocessing of the CSV-file
df = pd.read_csv(r'//a network drive/Path/To/A/Folder//YODA_2_0_FM.csv',header=None, sep=',', encoding='ANSI')

#Print the df to new csv incl header
df.to_csv(r'//a network drive/Path/To/A/Folder/YODA_2_0.csv', header=["LOTS","OF","COLUMNS"...], index=False)

# Step 2. Publish the csv as feature layer
# Connect to the GIS
gis = GIS(url='https://portal.my_company.com/portal', username='A Username', password='A password')

# Find the Yoda Feature Layer Collection in Portal
Yodafeaturelayer = gis.content.get('49604ab1b4854dca9734eca0a079358c')
Yoda_collection_layer = FeatureLayerCollection.fromitem(Yodafeaturelayer)

# Call the overwrite() method to overwrite with the new CSV
Yoda_collection_layer.manager.overwrite(r'//a network drive/Path/To/A/Folder/YODA_2_0.csv')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The csv that gets created on line 11 is always fine so there's no problem there.&lt;/P&gt;&lt;P&gt;Is there maybe some way of introducing a "check" in the script that performs before the overwrite function?&lt;BR /&gt;I guess there are more ways of making this workflow run, but this has worked fine for us, until it doesn't&amp;nbsp; that is &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;If anyone has any ideas on how we could secure this it would be highly appreciated as it is a highly demanded layer internally, that needs to be up and running asap...&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;BR,&lt;BR /&gt;Marcus&lt;/P&gt;</description>
    <pubDate>Sun, 04 Jul 2021 16:31:44 GMT</pubDate>
    <dc:creator>MarcusAndersson</dc:creator>
    <dc:date>2021-07-04T16:31:44Z</dc:date>
    <item>
      <title>FeatureLayerCollectionManager.overwrite crashes a layer in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollectionmanager-overwrite-crashes-a/m-p/1075489#M6315</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have a workflow that uses an export from a FileMaker-database, preprocesses it, and then "updates" (overwrites) a layer in a feature layer collection. The script below runs fine, until it doesn't! It usually runs for some 2-3 days before something fails during the publishing phase. This is scheduled through a *.bat-file to run once every hour, but once it has failed, the layer becomes empty and it's not possible to "repair" in any way.&lt;BR /&gt;The only way is to republish the data from zero, which then of course creates a new item-ID etc. Alas, this is not a viable solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Import used libraries
import pandas as pd
from arcgis.gis import GIS
from arcgis import features
from arcgis.features import FeatureLayerCollection

# Preprocessing of the CSV-file
df = pd.read_csv(r'//a network drive/Path/To/A/Folder//YODA_2_0_FM.csv',header=None, sep=',', encoding='ANSI')

#Print the df to new csv incl header
df.to_csv(r'//a network drive/Path/To/A/Folder/YODA_2_0.csv', header=["LOTS","OF","COLUMNS"...], index=False)

# Step 2. Publish the csv as feature layer
# Connect to the GIS
gis = GIS(url='https://portal.my_company.com/portal', username='A Username', password='A password')

# Find the Yoda Feature Layer Collection in Portal
Yodafeaturelayer = gis.content.get('49604ab1b4854dca9734eca0a079358c')
Yoda_collection_layer = FeatureLayerCollection.fromitem(Yodafeaturelayer)

# Call the overwrite() method to overwrite with the new CSV
Yoda_collection_layer.manager.overwrite(r'//a network drive/Path/To/A/Folder/YODA_2_0.csv')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The csv that gets created on line 11 is always fine so there's no problem there.&lt;/P&gt;&lt;P&gt;Is there maybe some way of introducing a "check" in the script that performs before the overwrite function?&lt;BR /&gt;I guess there are more ways of making this workflow run, but this has worked fine for us, until it doesn't&amp;nbsp; that is &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;If anyone has any ideas on how we could secure this it would be highly appreciated as it is a highly demanded layer internally, that needs to be up and running asap...&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;BR,&lt;BR /&gt;Marcus&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jul 2021 16:31:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollectionmanager-overwrite-crashes-a/m-p/1075489#M6315</guid>
      <dc:creator>MarcusAndersson</dc:creator>
      <dc:date>2021-07-04T16:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayerCollectionManager.overwrite crashes a layer in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollectionmanager-overwrite-crashes-a/m-p/1081046#M6378</link>
      <description>&lt;P&gt;Hi Markus,&lt;/P&gt;&lt;P&gt;See my comments here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/update-hosted-table-overwriting-it-with-local-csv/m-p/1078942#M6354" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-python-questions/update-hosted-table-overwriting-it-with-local-csv/m-p/1078942#M6354&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This approach may solve your problem and avoid the problem of a changing item id. You may, of course, have to tailor the code to your case.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 20:13:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/featurelayercollectionmanager-overwrite-crashes-a/m-p/1081046#M6378</guid>
      <dc:creator>emedina</dc:creator>
      <dc:date>2021-07-20T20:13:34Z</dc:date>
    </item>
  </channel>
</rss>

