Select to view content in your preferred language

None Type not Iterable: How to Resolve?

3251
2
Jump to solution
01-15-2021 08:02 AM
WilliamCole
Regular Contributor

This is for ArcGIS Desktop 10.8.1, Python 2.7.

 

The purpose of this script is to examine Attribute Tables associated with a set of Feature Classes and to extract from those tables a set of fields, writing those fields to a single csv file.

2021-01-14_15-53-49.png

The following script threw the error “’None Type’ object is not iterable” that was flagged on Line 20, highlighted in the figure below.

 

After reading several threads about None Type [here’s one from Geonet] I’ve decided that I’m just not smart enough to sort this out by myself nor have sufficient experience with Python to do so.

 

2021-01-14_15-53-49.png

 

Here’s what I’ve done to narrow things down:

 

  • Ran a script to print out the FC’s that would be listed by line 12. This gave me the expected answer.

  • Checked to make sure that the field names listed on line 26 were spelled and capitalized correctly. They were and were able to produce a csv file for a single FC.

 

To get to this point, I’ve been the beneficiary of help from several Geonet denizens for which I am very grateful. I hate to keep asking and not giving, but here I am and would be grateful, yet again, for some suggestion or two about what I should be looking for to resolve this error.

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
BlakeTerhune
MVP Regular Contributor

It's because fclist doesn't have any value; it's None. I suspect this is caused by you listing feature classes without setting an environment workspace. You can print(fclist) for debugging to verify. Where you have the comment that says "Set the workspace for ListFeatureClasses" you need to actually set the workspace 😉

 

workingDir = r"\\PANDA\..."
WorkingGDB = os.path.join(workingDir, "Burgess.mdb")
arcpy.env.workspace = workingGDB
fclist = arcpy.ListFeatureClasses("Ro*03")

 

View solution in original post

2 Replies
BlakeTerhune
MVP Regular Contributor

It's because fclist doesn't have any value; it's None. I suspect this is caused by you listing feature classes without setting an environment workspace. You can print(fclist) for debugging to verify. Where you have the comment that says "Set the workspace for ListFeatureClasses" you need to actually set the workspace 😉

 

workingDir = r"\\PANDA\..."
WorkingGDB = os.path.join(workingDir, "Burgess.mdb")
arcpy.env.workspace = workingGDB
fclist = arcpy.ListFeatureClasses("Ro*03")

 

WilliamCole
Regular Contributor

Thanks very much.  This solved that problem.  Looks like I need some more time learning the details of Python.  Be well, Bill Cole

0 Kudos