AnalyzeDatasets error

1056
2
Jump to solution
04-16-2018 02:37 PM
LarryAdgate
Occasional Contributor

I pulled this script directly off the help section of my ArcGis Desktop software and I'm surprised its giving me problems.

For my SQL Server, my objective is to analyze all my feature classes contained in my five datasets but I am getting an error as follows:  'NoneType' object is not iterable

Thank You for your assistance...Larry Adgate

# Name: AnalyzeDatasets.py
# Description: analyzes all datasets in an enterprise geodatabase
# for a given user.

# Import system modules
import arcpy, os

# set workspace
# the user in this workspace must be the owner of the data to analyze.
workspace = "Database Connections\\ArdenArden_gsw_sde_sde"

# set the workspace environment
arcpy.env.workspace = workspace

# NOTE: Analyze Datasets can accept a Python list of datasets.

# Get a list of all the datasets the user has access to.
dataList = arcpy.ListFeatureClasses()

# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.

#MY Error message is below:  TypeError: 'NoneType' object is not iterable
for dataset in arcpy.ListDatasets("*", "Feature"):
arcpy.env.workspace = os.path.join(workspace,dataset)
dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

# reset the workspace
arcpy.env.workspace = workspace

# Get the user name for the workspace
userName = arcpy.Describe(workspace).connectionProperties.user.lower()

# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]

# Execute analyze datasets
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", userDataList, "ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE")
print "Analyze Complete"

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JamesMacKay3
Occasional Contributor

ListDatasets will return a None value if the workspace path is incorrect and points to a non-existent location.  Your path ends with "ArdenArden_gsw_sde_sde" - is this missing a ".sde" extension, or perhaps the last underscore is supposed to be a period?  If you try to call arcpy.Describe() on that path, does it return a valid collection of properties or raise a runtime error?

View solution in original post

2 Replies
JamesMacKay3
Occasional Contributor

ListDatasets will return a None value if the workspace path is incorrect and points to a non-existent location.  Your path ends with "ArdenArden_gsw_sde_sde" - is this missing a ".sde" extension, or perhaps the last underscore is supposed to be a period?  If you try to call arcpy.Describe() on that path, does it return a valid collection of properties or raise a runtime error?

LarryAdgate
Occasional Contributor

Thank You James for your help..............After correcting my workspace using your arcpy.Description() method, the script seemed have issues opening one of the datasets. But after removing the pipeline geometric network,  the script worked fine.....Once again thank You 

0 Kudos