1

I'm new to python and this is my script:

import arcpy,sys
input=sys.argv[1]
field=sys.argv[2]
try:
    cursor=arcpy.da.SearchCursor(input,field)
    getvalue=[row.getValue(field) for row in cursor]
    values=set(getvalue)
    print values
    del cursor
except:
    del cursor

When its trying to run cursor, the following error appeared:

Traceback (most recent call last):
  File "C:\Users\Erfan\Desktop\Script2.py", line 6, in <module>
    cursor=arcpy.da.SearchCursor(input,field)
RuntimeError: cannot open 'D:\gis\data\network'

By the way, I want to access a feature class inside a feature dataset in gdb.

2
  • 4
    'D:\gis\data\network' isn't a path to a feature class within a feature dataset within a gdb
    – GISGe
    Nov 22 '16 at 12:44
  • 3
    The row.getValue() method applies to the old arcpy cursors, not to the (not so) new arcpy.da cursors.
    – GISGe
    Nov 22 '16 at 12:49
5

Your argument 1 path should be something like this to reference a gdb feature dataset feature class (as a python string):

'D:/gis/data/network/test.gdb/myFeatureDataset/myFC' # also back slashes will error out interpreted as line returns by python, use forward slashes instead

And as @GISGe commented, getValue() method is for the older cursor type, use row[0] instead (for first field in field variable list or row[1] for second field in field variable list). See examples here, Search Cursor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy