I'm running ListFeatureClasses() on every Feature Dataset in my SDE using arcpy - the line goes something like this:
FDS = arcpy.ListFeatureDatasets()
for FD in FDS:
arcpy.env.workspace = FD
print arcpy.ListFeatureClasses()
But for some of the feature datasets that I know (and can load data from), nothing is returned. Has anyone ever gotten this issue?
Try this:
Set the workspace before the loop:
env.workspace = r"/path/to/geodatabase"
Set the feature dataset list:
datasets = arcpy.ListDatasets("*", "FeatureClass")
Set a list to contain the feature datasets:
fds = [fc for fc in datasets]
Loop through the feature datasets grabbing their feature classes:
for fd in fds:
fc = arcpy.ListFeatureClasses("*", "ALL", fd)
print "{}: {}".format(fd, fc)
Full snippet:
from arcpy import env
import arcpy
env.workspace = r"path/to/geodatabase"
datasets = arcpy.ListDatasets("*", "FeatureClass")
fds = [fc for fc in datasets]
for fd in fds:
fc = arcpy.ListFeatureClasses("*", "ALL", fd)
print "{}: {}".format(fd, fc)`
ListFeatureClasses (arcpy)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With