ListFeatureClasses returns '[ ]'

758
2
09-17-2013 05:36 PM
StephenPage
New Contributor
Hi,

I'm not able to get the ListFeatureClasses working!

This is a pretty basic code, and I've seen many examples, including in the ESRI 10.1 Help

Note that 'Exists' works!
But not ListFeatureClasses, ListDatasets, ListFiles... - these return '[ ]'

Files are on my C drive (local Hard drive)

Thanks,

Steve

import arcpy
from arcpy import env

env.workspace = "C:/drainagescripting/inputdata/drainagedatasp.gdb"

# THIS WORKS - prints 'true'
print arcpy.Exists("C:/drainagescripting/inputdata/drainagedatasp.gdb")

# THESE return '[ ]'
fclist = arcpy.ListFeatureClasses()
print fclist
Tags (2)
0 Kudos
2 Replies
jp
by
New Contributor II

If the feature classes reside in feature dataset then you need to include the feature dataset name in the path. 

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I'm not sure why it wouldn't work for you, assuming there is actually some feature classes in the .gdb.

I modified you code slightly

import arcpy  
from arcpy import env  

env.workspace = theWorkspace = "C:/__temp/test.gdb"  

# THIS WORKS - prints 'true'  
print arcpy.Exists(theWorkspace)  

# THESE return '[ ]'  
fclist = arcpy.ListFeatureClasses()  
print (fclist)

and my results were..

True
[u'newpts', u'newPtsMySR', u'test', u'testout2', u'StudyZones', u'bl00_point']

so, take a look at your .gdb to see what is in there.

0 Kudos