<?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: Overwrite AGOL feature service without overwriting field aliases and descriptions in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480148#M10078</link>
    <description>&lt;P&gt;You have two options:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Keep doing what you're doing but add an additional step that updates the feature layer definition to reapply the aliases and descriptions. For this, you'll need to access the FeatureLayer you want to update from the FeatureLayerCollection and then save the fields properties somewhere before you overwrite (FeatureLayer.properties.fields). On overwrite, you will use the FeatureLayer.update_definition() and supply the fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Truncate/append instead of overwriting. I like this option better because it's faster and results in less service downtime.&lt;/P&gt;&lt;P&gt;This example assumes you have geometry to parse. If you don't then use "df" instead of "sedf" :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import pandas as pd
from arcgis import GIS
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.features import FeatureLayer

gis = GIS()
url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Earthquakes_Since1970/FeatureServer/0"
fl = FeatureLayer(url, gis)

csv_path = "/path/to/xy.csv"
df = pd.read_csv(csv_path)
sedf = pd.DataFrame.spatial.from_xy(df=df, x_column="LONGITUDE", y_column="LATITUDE", sr=4326)

adds = sedf.spatial.to_featureset()
fl.manager.truncate()
fl.edit_features(adds=adds)&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;Note for this to work you have to point to individual layer you want to update with new data.&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 12:50:46 GMT</pubDate>
    <dc:creator>EarlMedina</dc:creator>
    <dc:date>2024-05-30T12:50:46Z</dc:date>
    <item>
      <title>Overwrite AGOL feature service without overwriting field aliases and descriptions</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1479906#M10076</link>
      <description>&lt;P&gt;Hello. I am using the&amp;nbsp;&lt;SPAN&gt;FeatureLayerCollection.manager.overwrite() function to overwrite an AGOL hosted feature service with the contents of a csv file. Something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lookup_table = connection_to_agol.content.get(file['agolItemId'])     
feature_layer_collection = FeatureLayerCollection.fromitem(lookup_table)
response = feature_layer_collection.manager.overwrite(csv_file)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is working as expected, but all field aliases and descriptions for the hosted feature service are also overwritten when i overwrite the data. I'd like to not have to re-create that information every time the feature service is updated programmatically. Is there a different approach i can use to overwrite the data from a csv file while preserving the field aliases and descriptions?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;thank you&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 May 2024 00:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1479906#M10076</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2024-05-29T00:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite AGOL feature service without overwriting field aliases and descriptions</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480148#M10078</link>
      <description>&lt;P&gt;You have two options:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Keep doing what you're doing but add an additional step that updates the feature layer definition to reapply the aliases and descriptions. For this, you'll need to access the FeatureLayer you want to update from the FeatureLayerCollection and then save the fields properties somewhere before you overwrite (FeatureLayer.properties.fields). On overwrite, you will use the FeatureLayer.update_definition() and supply the fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Truncate/append instead of overwriting. I like this option better because it's faster and results in less service downtime.&lt;/P&gt;&lt;P&gt;This example assumes you have geometry to parse. If you don't then use "df" instead of "sedf" :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import pandas as pd
from arcgis import GIS
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.features import FeatureLayer

gis = GIS()
url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Earthquakes_Since1970/FeatureServer/0"
fl = FeatureLayer(url, gis)

csv_path = "/path/to/xy.csv"
df = pd.read_csv(csv_path)
sedf = pd.DataFrame.spatial.from_xy(df=df, x_column="LONGITUDE", y_column="LATITUDE", sr=4326)

adds = sedf.spatial.to_featureset()
fl.manager.truncate()
fl.edit_features(adds=adds)&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;Note for this to work you have to point to individual layer you want to update with new data.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 12:50:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480148#M10078</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-05-30T12:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite AGOL feature service without overwriting field aliases and descriptions</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480266#M10079</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;. Option 2 sounds way better. I'll give that a try and let you know how it goes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 15:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480266#M10079</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2024-05-29T15:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite AGOL feature service without overwriting field aliases and descriptions</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480552#M10082</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your suggestion. I ended up doing a truncate / append. Instead of using the &lt;STRONG&gt;edit_features()&lt;/STRONG&gt; method on the FeatureLayer, i am using the &lt;STRONG&gt;append() &lt;/STRONG&gt;method&amp;nbsp;on my Table (my data has no spatial component). There's a bit more futzing around with uploading and deleting the source csv file, but its working for now.&lt;/P&gt;&lt;P&gt;If you've got some extra time (and no worries if you don't!), could you explain more about how i could of done this with a pandas data frame. I was intrigued by your comment:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;This example assumes you have geometry to parse. If you don't then use "df" instead of "sedf"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I poked around a bit, but couldn't figure out how to use the data frame as the source for the 'edit_features()'. I&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 20:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480552#M10082</guid>
      <dc:creator>Trippetoe</dc:creator>
      <dc:date>2024-05-29T20:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite AGOL feature service without overwriting field aliases and descriptions</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480562#M10083</link>
      <description>&lt;P&gt;Oh, so you would basically just do this and I think it should work:&lt;BR /&gt;&lt;BR /&gt;&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="c"&gt;sedf = pd.DataFrame.spatial.from_df(df)
adds = sedf.spatial.to_featureset()
fl.manager.truncate()
fl.edit_features(adds=adds)&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't remember if the result includes a SHAPE column, but if it does you could simply drop it before creating the featureset. There is a Table object you can use (although you can actually also just use FeatureLayer without a problem) which also has edit_features.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/339785"&gt;@Trippetoe&lt;/a&gt;&amp;nbsp;Sorry, I realized I was using "updates" instead of "adds" before. Updated all the samples accordingly. You would use "updates" in the case that you were simply updating attributes in the data.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 12:52:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/overwrite-agol-feature-service-without-overwriting/m-p/1480562#M10083</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-05-30T12:52:42Z</dc:date>
    </item>
  </channel>
</rss>

