bwscim

SearchCursor - RuntimeError: cannot open - Feature Class

Discussion created by bwscim on Jul 23, 2017
Latest reply on Jul 24, 2017 by Alexander_Brown-esristaff

I'm attempting to read a specific field from a Feature Class using the following code (search cursor):

import arcpy
import os

arcpy.env.workspace = 'C:\Users\jas\Documents\ArcGIS\L_Sr_geodatabase.gdb'

#inputFeatures = arcpy.GetParameterAsText(0)
inFeatures = 'LF_Stormdrains'

fc = os.path.join(arcpy.env.workspace,inFeatures)

# check if exist
if arcpy.Exists(fc):
   print "Feature Class Exists"

# check name
fc_list = arcpy.ListFeatureClasses()   

for fcname in fc_list: 
    arcpy.AddMessage(fcname)


fields = ['ASSET_ID']

if arcpy.Exists(inFeatures):
     arcpy.AddMessage("Feature Class Exists...")

with arcpy.da.SearchCursor(fc, fields) as cursor:
     try:
          if cursor.next() != ():
               cursor.reset()
               for row in cursor:
                    assetID = row[0]
                    arcpy.AddMessage(assetID)
     except StopIteration:
          print('Empty Cursor')

I'm stumped on the RuntimeError: cannot open 'feature class'.  Any help would be appreciated!

Outcomes