Why is this Table not a table?
At first I had 'Table' in the type parameter and got [ ]. Then I found out the Table is actually a 'Feature Layer Collection'.
So, that's great. Or so I thought. But, then I get an error telling me the table is not a table?
with arcpy.da.SearchCursor(table, fields) as cursor:
for row in cursor:
description_dict[row[1]] = row[0]
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-21-bdc66f453653> in <module>
13 description_dict = {}
14
---> 15 with arcpy.da.SearchCursor(table, fields) as cursor:
16 for row in cursor:
17 description_dict[row[1]] = row[0]
RuntimeError: 'in_table' is not a table or a featureclass
I then tried the Green Descriptions CSV but got the same error.
with arcpy.da.SearchCursor(csv, fields) as cursor:
for row in cursor:
description_dict[row[1]] = row[0]
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-22-b36d2a96d554> in <module>
13 description_dict = {}
14
---> 15 with arcpy.da.SearchCursor(csv, fields) as cursor:
16 for row in cursor:
17 description_dict[row[1]] = row[0]
RuntimeError: 'in_table' is not a table or a featureclass
I've came across a similar thread posted earlier this year that was never answered Convert from Feature Collection to Feature Class
Solved! Go to Solution.
Eric Samson, the short answer to both Jared Pilbeam and yourself is that your Item in AGOL/Portal is not a table:
>>> items = gis.content.search("SampleCSV")
>>> item = items[0]
>>> item
<Item title:"SampleCSV" type:CSV owner:me>
>>> type(item)
<class 'arcgis.gis.Item'>
>>>
You aren't passing a table to the cursor, you are passing a GIS Item to the cursor that contains a CSV. A GIS Item containing a table isn't the same as a table.
To use the CSV table in the GIS Item with a cursor, you either need to publish the CSV as a hosted service or download the CSV to disk.
Currently having the same issue
Eric Samson, the short answer to both Jared Pilbeam and yourself is that your Item in AGOL/Portal is not a table:
>>> items = gis.content.search("SampleCSV")
>>> item = items[0]
>>> item
<Item title:"SampleCSV" type:CSV owner:me>
>>> type(item)
<class 'arcgis.gis.Item'>
>>>
You aren't passing a table to the cursor, you are passing a GIS Item to the cursor that contains a CSV. A GIS Item containing a table isn't the same as a table.
To use the CSV table in the GIS Item with a cursor, you either need to publish the CSV as a hosted service or download the CSV to disk.