<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: NoneType object is not iterable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561048#M73215</link>
    <description>&lt;P&gt;Hi, it sounds like there are no new unprocessed point feature classes and you need to introduce some code to manage cases when gpsPointList returns None. Perhaps some change upstream has impacted your workflow?&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;import sys&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;gpsPointList = arcpy.ListFeatureClasses(feature_type=pnt)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;if gpsPointList is None:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; gpsPointList = []&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; print("No gpsPoint feature classes. Exit script")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; sys.exit()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;else:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; gpsPointList = list(gpsPointList)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; print(gpsPointList)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; # continue with script&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2024 22:29:36 GMT</pubDate>
    <dc:creator>Yuriko</dc:creator>
    <dc:date>2024-11-20T22:29:36Z</dc:date>
    <item>
      <title>NoneType object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561005#M73214</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script to perform a simple everyday task I have to do at work that had been working well (for years) until recently. The script looks through a GDB to find unprocessed point FCs and turns them into smooth lines. However, recently I have been receiving the following error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "E:\MapFiles\Trails\TrailConditionMonitoring\OSMP_TrailAlignData\PointsToLineArcPro.py", line 9, in &amp;lt;module&amp;gt;&lt;BR /&gt;gpsPointList = list((arcpy.ListFeatureClasses(feature_type=pnt)))&lt;BR /&gt;TypeError: 'NoneType' object is not iterable&lt;/P&gt;&lt;P&gt;I'm unsure why the script worked for so long then all of a sudden threw this error. Why could I iterate through the list of feature classes before, but not now? Any help would be appreciated! The script is posted below.&lt;/P&gt;&lt;P&gt;# A script that looks through a GDB to find point fcs that need to be processed into smooth lines and processes them&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;# set workspace&lt;BR /&gt;wksp = arcpy.env.workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;# define variables for point and line features&lt;BR /&gt;pnt = "Point"&lt;BR /&gt;gpsPointList = list((arcpy.ListFeatureClasses(feature_type=pnt)))&lt;BR /&gt;print(gpsPointList)&lt;BR /&gt;line = "Line"&lt;BR /&gt;existingLines = list((arcpy.ListFeatureClasses(feature_type=line)))&lt;BR /&gt;print(existingLines)&lt;/P&gt;&lt;P&gt;# set up loop to add smooth text to the end of the point feature classes&lt;BR /&gt;smooth = "Smooth"&lt;BR /&gt;strPoint = ""&lt;BR /&gt;checkPoints = []&lt;BR /&gt;for points in gpsPointList:&lt;BR /&gt;strPoint = points + smooth&lt;BR /&gt;checkPoints.append(strPoint)&lt;/P&gt;&lt;P&gt;print(checkPoints)&lt;/P&gt;&lt;P&gt;# Set up list variables to store already processed and unprocessed point features&lt;BR /&gt;processedPoints = []&lt;BR /&gt;unprocessedPoints = []&lt;/P&gt;&lt;P&gt;# set up to iterate through the point feature classes to find duplicates(processed points)&lt;BR /&gt;unPointStr = ""&lt;BR /&gt;for pointfc in checkPoints:&lt;BR /&gt;if pointfc in existingLines:&lt;BR /&gt;processedPoints.append(pointfc)&lt;BR /&gt;else:&lt;BR /&gt;unPointStr = pointfc[:-6]&lt;BR /&gt;unprocessedPoints.append(unPointStr)&lt;/P&gt;&lt;P&gt;# Use exception handling to stop code if no point fcs need to be processed&lt;BR /&gt;if len(unprocessedPoints) == 0:&lt;BR /&gt;raise Exception("All point feature classes have been processed.")&lt;BR /&gt;else:&lt;BR /&gt;print(unprocessedPoints, "\n", len(unprocessedPoints), "point feature classes ready to process.")&lt;/P&gt;&lt;P&gt;# Iterate through unprocessed point fcs to turn them into smooth lines&lt;BR /&gt;sr = arcpy.SpatialReference(6429) # Code for NAD1983 (2011) StatePlane Colorado North FIPS&lt;BR /&gt;project = ""&lt;BR /&gt;ptsToLine = ""&lt;BR /&gt;for unpro in unprocessedPoints:&lt;BR /&gt;try:&lt;BR /&gt;# Project points to match other city data&lt;BR /&gt;project = unpro + "project"&lt;BR /&gt;arcpy.Project_management(unpro, project, sr)&lt;BR /&gt;print(project)&lt;/P&gt;&lt;P&gt;# Turn points into line&lt;BR /&gt;ptsToLine = project + "Line"&lt;BR /&gt;linefield = "RID"&lt;BR /&gt;arcpy.PointsToLine_management(project, ptsToLine, linefield)&lt;BR /&gt;print(ptsToLine)&lt;/P&gt;&lt;P&gt;# Smooth the line for a nice finished product&lt;BR /&gt;smoothLine = unpro + "Smooth"&lt;BR /&gt;alg = "PAEK" # algorithm for smoothing&lt;BR /&gt;tolerance = 5 # tolerance for smoothing&lt;BR /&gt;arcpy.SmoothLine_cartography(ptsToLine, smoothLine, alg, tolerance)&lt;BR /&gt;print(smoothLine + " Processed")&lt;/P&gt;&lt;P&gt;# delete intermediate data&lt;BR /&gt;arcpy.Delete_management(ptsToLine)&lt;BR /&gt;arcpy.Delete_management(project)&lt;/P&gt;&lt;P&gt;# use iteration to create a trail name for a new field&lt;BR /&gt;trail = smoothLine[:-12]&lt;BR /&gt;trail2 = ""&lt;/P&gt;&lt;P&gt;for i in range(len(trail)):&lt;BR /&gt;if (trail[i].isupper()):&lt;BR /&gt;trail2 += " "&lt;BR /&gt;trail2 += trail[i]&lt;BR /&gt;else:&lt;BR /&gt;trail2 += trail[i]&lt;BR /&gt;trailName = trail2[1:]&lt;BR /&gt;print(trailName)&lt;/P&gt;&lt;P&gt;# use cursor to add trail name field to smooth line fc&lt;BR /&gt;nameField = "TrailName"&lt;BR /&gt;arcpy.AddField_management(smoothLine, nameField, "TEXT")&lt;BR /&gt;print("Trail Name field added")&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(smoothLine, nameField) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;row[0] = trailName&lt;BR /&gt;cursor.updateRow(row)&lt;BR /&gt;print(trailName + " added")&lt;BR /&gt;del cursor, row&lt;/P&gt;&lt;P&gt;except:&lt;BR /&gt;print("Something went wrong check your unprocessed point list" + "\n" + unprocessedPoints)&lt;/P&gt;&lt;P&gt;print("Processing Complete")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 21:09:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561005#M73214</guid>
      <dc:creator>JacobEngelman</dc:creator>
      <dc:date>2024-11-20T21:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: NoneType object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561048#M73215</link>
      <description>&lt;P&gt;Hi, it sounds like there are no new unprocessed point feature classes and you need to introduce some code to manage cases when gpsPointList returns None. Perhaps some change upstream has impacted your workflow?&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;import sys&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;gpsPointList = arcpy.ListFeatureClasses(feature_type=pnt)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;if gpsPointList is None:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; gpsPointList = []&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; print("No gpsPoint feature classes. Exit script")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; sys.exit()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;else:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; gpsPointList = list(gpsPointList)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; print(gpsPointList)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; # continue with script&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 22:29:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561048#M73215</guid>
      <dc:creator>Yuriko</dc:creator>
      <dc:date>2024-11-20T22:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: NoneType object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561267#M73220</link>
      <description>&lt;P&gt;i would start with checking your workspace. Also, if you arcpy.ListFeatureClasses() returns none, might be an issue. Try this,&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

# set workspace
wksp = arcpy.env.workspace = arcpy.GetParameterAsText(0)
print(f"Workspace: {wksp}")

# define variables for point and line features
pnt = "Point"
gpsPointList = arcpy.ListFeatureClasses(feature_type=pnt)
print(f"GPS Point List: {gpsPointList}")

if gpsPointList is None:
    raise Exception("No point feature classes found in the workspace.")

gpsPointList = list(gpsPointList)
line = "Line"
existingLines = arcpy.ListFeatureClasses(feature_type=line)
print(f"Existing Lines: {existingLines}")

if existingLines is None:
    raise Exception("No line feature classes found in the workspace.")

existingLines = list(existingLines)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Nov 2024 15:26:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nonetype-object-is-not-iterable/m-p/1561267#M73220</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-11-21T15:26:42Z</dc:date>
    </item>
  </channel>
</rss>

