Insert data in a table layer ArcGIS online with python error out

166
0
11-29-2023 10:06 AM
manishcal16
New Contributor

Hi All,

follow previous site- https://community.esri.com/t5/python-questions/insert-data-in-a-table-layer-arcgis-online-with/td-p/...

from arcgis.gis import GIS
import getpass


table_item_id = ""
gis = GIS(
url="https://www.arcgis.com/",
username="******",
password=getpass.getpass("enter password:")
)

hosted_table_item = gis.content.search(table_item_id)[3]

table = hosted_table_item.tables[3]
new_data = [{'attributes': {'OBJECTID': '2', 'Temp': '2'}}]
table.edit_features(adds=new_data)

 

but it is error out, error message

--------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~\anaconda3\Lib\site-packages\arcgis\gis\__init__.py in ?(self, k)
  13202             if not self._hydrated and not k.startswith("_"):
  13203                 self._hydrate()
> 13204             return dict.__getitem__(self, k)

KeyError: 'tables'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_12232\2640506681.py in ?()
     10 )
     11 
     12 hosted_table_item = gis.content.search(table_item_id)[3]
     13 
---> 14 table = hosted_table_item.tables[3]
     15 new_data = [{'attributes': {'OBJECTID': '2', 'Temperature': '23.3'}}]
     16 table.edit_features(adds=new_data)

~\anaconda3\Lib\site-packages\arcgis\gis\__init__.py in ?(self, name)
  13170                         print(e)
  13171                     pass
  13172                 return self["layers"]
  13173         elif name == "tables":
> 13174             if self["tables"] == None or self["tables"] == []:
  13175                 try:
  13176                     with _common_utils._DisableLogger():
  13177                         self._populate_layers()

~\anaconda3\Lib\site-packages\arcgis\gis\__init__.py in ?(self, k)
  13200             return dict.__getitem__(self, k)
  13201         except KeyError:
  13202             if not self._hydrated and not k.startswith("_"):
  13203                 self._hydrate()
> 13204             return dict.__getitem__(self, k)

KeyError: 'tables'

please help

 

Tags (2)
0 Kudos
0 Replies