<?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: Add and edit fields in ArcGIS Online hosted Feature Layer table using Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1187703#M7519</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/483985"&gt;@Manu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to use the url of the table/layer when interacting AGOL items with arcpy.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;species_table = AGOL_survey_layer.tables[0].url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 09:55:55 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2022-06-29T09:55:55Z</dc:date>
    <item>
      <title>Add and edit fields in ArcGIS Online hosted Feature Layer table using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1141049#M7090</link>
      <description>&lt;P&gt;I have a FeatureLayer on ArcGIS Online. It contains a Layer and a Table. Now, I want to add columns to that table (in case they were not already added) and update the values for the cells in those columns based on another column. I tried this from an ArcGIS Pro Python Notebook:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;gis = GIS("pro")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ArcGIS_content = "my_feature_layer_ID"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;## get ArcGIS Online layer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;AGOL_survey_layer = gis.content.get(ArcGIS_content)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;# get table&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;species_table = AGOL_survey_layer.tables[0]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;species_table_df = species_table.query(as_df = True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;table_fields = list(species_table_df.columns.values)&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;# add new fields, if not already present&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;new_fields = ["field0", "field1", "field2"]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;for field in new_fields:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field not in table_fields:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.AddField(species_table, field_name = field,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_type = "TEXT")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;# update field values&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;search_cursor = arcpy.da.SearchCursor(species_table, ["input_field"])&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;update_cursor = arcpy.da.UpdateCursor(species_table, new_fields)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;for row_search, row_update in zip(search_cursor, update_cursor):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = row_search&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row_update.updateRow(["valueField0", "vaueField1", "valueField2"])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;However, this won't work. E.g., it outputs&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;RuntimeError: 'in_table' is not a table or a featureclass&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve the issues here? The examples on pro.arcgis.com show only examples for offline tables. However, I do not want to download anything. It should update the hosted FeatureLayer's table directly on ArcGIS Online.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 09:44:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1141049#M7090</guid>
      <dc:creator>Manu</dc:creator>
      <dc:date>2022-02-07T09:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add and edit fields in ArcGIS Online hosted Feature Layer table using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1187703#M7519</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/483985"&gt;@Manu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to use the url of the table/layer when interacting AGOL items with arcpy.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;species_table = AGOL_survey_layer.tables[0].url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 09:55:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1187703#M7519</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2022-06-29T09:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add and edit fields in ArcGIS Online hosted Feature Layer table using Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1476706#M10056</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I realize this is an old topic, but I stumbled upon this from Google and wanted to clarify that for me,&amp;nbsp;&amp;lt;layer_name&amp;gt;.layers[0].url worked instead.&lt;/P&gt;&lt;P&gt;Thank you for contributing your answer!&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 00:54:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/add-and-edit-fields-in-arcgis-online-hosted/m-p/1476706#M10056</guid>
      <dc:creator>MapOfTheSolutionatique</dc:creator>
      <dc:date>2024-05-22T00:54:16Z</dc:date>
    </item>
  </channel>
</rss>

