'in_table' is not a table or a featureclass

1201
2
Jump to solution
07-08-2020 12:09 PM
JaredPilbeam2
MVP Regular Contributor

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 

1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

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.

View solution in original post

2 Replies
EricSamson1
New Contributor II

Currently having the same issue

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

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.