<?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 or update hosted table with new fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1317523#M68374</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hey! I'm curious about how you resolved your problem. Currently, the only solution I can follow is what you mentioned earlier. I make sure the layer is originally published in ArcGIS Pro, and then, when I overwrite the web layer from within ArcGIS Pro, the new columns do appear. How did you handle this on your end?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2023 17:33:30 GMT</pubDate>
    <dc:creator>JonJones1</dc:creator>
    <dc:date>2023-08-10T17:33:30Z</dc:date>
    <item>
      <title>Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1045835#M60738</link>
      <description>&lt;P&gt;I am trying to update a hosted table in AGOL (published from a CSV). The updated CSV has the same name and structure except a new field. When I try to update or overwrite the table, both manually from AGOL and using script with Python API the new field is not added to the hosted table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried to add the field (both manually from AGOL and using 'Add field' in Python) prior to the overwritting but when I overwrite the new field dissapears.&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Overwrite CSV&lt;BR /&gt;oldcsv = gis.content.get('itemid')&lt;BR /&gt;oldcsvFLC = FeatureLayerCollection.fromitem(oldcsv)&lt;BR /&gt;oldcsvFLC.manager.overwrite('path')&lt;/P&gt;&lt;P&gt;I attach a subset of old and new CSV as an example&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 07:48:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1045835#M60738</guid>
      <dc:creator>IonSola_Torralba</dc:creator>
      <dc:date>2021-04-12T07:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1045890#M60740</link>
      <description>&lt;P&gt;Changing the schema during an overwrite can lead to problems. It &lt;EM&gt;is &lt;/EM&gt;technically possible, but &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html#arcgis.features.managers.FeatureLayerCollectionManager.overwrite" target="_self"&gt;the docs themselves&lt;/A&gt; advise against this.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;4. The schema (column names, column data types) of the data_file should be the same as original. You can have additional or fewer rows (features).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Try adding the field to your hosted layer first, then overwriting.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 13:14:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1045890#M60740</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-04-12T13:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1055601#M61073</link>
      <description>&lt;P&gt;Thank you, but I already tried that, and it didn't work. I add the field to my hosted layer with no problem, but after the overwrite this new field dissapears again.&lt;/P&gt;&lt;P&gt;The overwriting works fine from ArcGIS PRO if the original table was shared from ArcGIS PRO too, but when I try to overwrite a table in AGOL which was published from a CSV the overwriting doesn't create new fields.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 11:36:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1055601#M61073</guid>
      <dc:creator>IonSola_Torralba</dc:creator>
      <dc:date>2021-05-07T11:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1118972#M63020</link>
      <description>&lt;P&gt;Hey, I have also experienced this exact issue. My only solution has been to recreate everything to add the new field(s). This method is not ideal and is super time consuming. Have you been able to find a workaround or an alternative solution?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 20 Nov 2021 01:41:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1118972#M63020</guid>
      <dc:creator>LARAPAdmin</dc:creator>
      <dc:date>2021-11-20T01:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1190444#M64959</link>
      <description>&lt;P&gt;I'm having this same problem.&amp;nbsp; Has a solution been identified yet?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 16:27:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1190444#M64959</guid>
      <dc:creator>jayt70</dc:creator>
      <dc:date>2022-07-07T16:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1195838#M65064</link>
      <description>&lt;P&gt;As far as I know, there is no solution for a key issue like this. Managing hosted tables in AGOL is clearly&amp;nbsp; improvable. The only workaround I know is deleting the old table, publishing the new table and replace the itemid of the table everywhere. I share the script. I hope it helps:&lt;/P&gt;&lt;P&gt;# Importe las bibliotecas necesarias.&lt;BR /&gt;from arcgis.gis import GIS, Item&lt;/P&gt;&lt;P&gt;# Cree una conexión al usuario de ArcGIS Online o Portal for ArcGIS deseado.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;user = "XXXXXXXX" # introduzca el usuario deseado&lt;BR /&gt;password = "XXXXXXXX" # introduzca la contraseña&lt;/P&gt;&lt;P&gt;url = "&lt;A href="https://www.arcgis.com" target="_blank"&gt;https://www.arcgis.com&lt;/A&gt;" # cambie la URL de Portal si es necesario&lt;BR /&gt;gis = GIS(url, user, password)&lt;BR /&gt;me = gis.users.me&lt;BR /&gt;my_items = me.items(max_items=500000)&lt;/P&gt;&lt;P&gt;# ItemIDs&lt;BR /&gt;old = "olditemid"&lt;BR /&gt;new = "newitemid"&lt;/P&gt;&lt;P&gt;carpetas = ['Name of AGOL folder where data is stored']&lt;/P&gt;&lt;P&gt;itemTypes = ['Dashboard']&lt;/P&gt;&lt;P&gt;# Help: &lt;A href="https://developers.arcgis.com/python/sample-notebooks/clone-portal-users-groups-and-content/" target="_blank"&gt;https://developers.arcgis.com/python/sample-notebooks/clone-portal-users-groups-and-content/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;folders = me.folders&lt;BR /&gt;for folder in folders:&lt;BR /&gt;carpeta = folder['title']&lt;BR /&gt;if carpeta in carpetas:&lt;BR /&gt;print('__________________________________')&lt;BR /&gt;print(' ')&lt;BR /&gt;print('Carpeta: ' + folder['title'])&lt;BR /&gt;print('__________________________________')&lt;BR /&gt;print(' ')&lt;BR /&gt;folder_items = me.items(folder=folder['title'],max_items=5000)&lt;BR /&gt;if len(folder_items)&amp;gt;0:&lt;BR /&gt;for item in folder_items:&lt;BR /&gt;# Si encuentra algún itemid viejo printa el item, el número de veces que se accede a ese itemid y los sustituye&lt;BR /&gt;if item.type in itemTypes:&lt;BR /&gt;#print(item.title + '. Tipo: ' + item.type)&lt;BR /&gt;itemid = item.id&lt;BR /&gt;# Recupere los datos de la aplicación.&lt;BR /&gt;app = Item(gis, itemid)&lt;BR /&gt;appdata = app.get_data(False)&lt;BR /&gt;&lt;BR /&gt;# Saber el número de veces que se utiliza item viejo&lt;BR /&gt;pattern = old&lt;BR /&gt;count =0&lt;BR /&gt;flag=True&lt;BR /&gt;start=0&lt;BR /&gt;&lt;BR /&gt;if appdata != None: # Si no hay texto no entra al loop&lt;BR /&gt;&lt;BR /&gt;while flag:&lt;BR /&gt;a = appdata.find(pattern,start) # find() returns -1 if the word is not found,&lt;BR /&gt;#start i the starting index from the search starts(default value is 0)&lt;BR /&gt;if a==-1: #if pattern not found set flag to False&lt;BR /&gt;flag=False&lt;BR /&gt;else: # if word is found increase count and set starting index to a+1&lt;BR /&gt;count+=1&lt;BR /&gt;start=a+1&lt;BR /&gt;&lt;BR /&gt;if count &amp;gt; 0:&lt;BR /&gt;print(item.title + '. Tipo: ' + item.type)&lt;BR /&gt;print('Se han encontrado ' + str(count) + ' items viejos')&lt;BR /&gt;&lt;BR /&gt;# Ejecute el script para sustituir itemid viejo por nuevo en los datos de la aplicación.&lt;BR /&gt;new_appdata = appdata.replace(old, new)&lt;BR /&gt;&lt;BR /&gt;# Comprobar si queda algún itemid viejo a sustituir&lt;BR /&gt;count =0&lt;BR /&gt;flag=True&lt;BR /&gt;start=0&lt;BR /&gt;while flag:&lt;BR /&gt;a = new_appdata.find(pattern,start) # find() returns -1 if the word is not found,&lt;BR /&gt;#start i the starting index from the search starts(default value is 0)&lt;BR /&gt;if a==-1: #if pattern not found set flag to False&lt;BR /&gt;flag=False&lt;BR /&gt;else: # if word is found increase count and set starting index to a+1&lt;BR /&gt;count+=1&lt;BR /&gt;start=a+1&lt;BR /&gt;print('Tras la sustitución, quedan ' + str(count) + ' items viejos')&lt;BR /&gt;&lt;BR /&gt;# Actualice el elemento con la URL especificada en el paso 5 e imprima una sentencia de cierre.&lt;BR /&gt;app.update({"text": new_appdata})&lt;BR /&gt;&lt;BR /&gt;print("El item con nombre " + item.title + " ha sido actualizado con éxito")&lt;BR /&gt;print(' ')&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 10:04:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1195838#M65064</guid>
      <dc:creator>IonSola_Torralba</dc:creator>
      <dc:date>2022-07-26T10:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Overwrite or update hosted table with new fields</title>
      <link>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1317523#M68374</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hey! I'm curious about how you resolved your problem. Currently, the only solution I can follow is what you mentioned earlier. I make sure the layer is originally published in ArcGIS Pro, and then, when I overwrite the web layer from within ArcGIS Pro, the new columns do appear. How did you handle this on your end?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 17:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/overwrite-or-update-hosted-table-with-new-fields/m-p/1317523#M68374</guid>
      <dc:creator>JonJones1</dc:creator>
      <dc:date>2023-08-10T17:33:30Z</dc:date>
    </item>
  </channel>
</rss>

