<?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: TypeError: 'FeatureLayer' object is not iterable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094316#M62219</link>
    <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've managed to get it working&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gis = GIS("home")
xxM = gis.content.get("54e2xxxeae")
xxLive = xxM.layers[11]&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;NewxxLive = xxLive.query(where = "OBJECTID = 11")&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;print("--Start Run--")
for feature in NewxxLive:
    print("---Start--")
    print(feature)
    print("----")&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;--Start Run--
---Start--
{"geometry": {"paths": [[[51....]]]}, "attributes": {"OBJECTID": 11 }}
----&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 01 Sep 2021 10:49:36 GMT</pubDate>
    <dc:creator>StuartMoore</dc:creator>
    <dc:date>2021-09-01T10:49:36Z</dc:date>
    <item>
      <title>TypeError: 'FeatureLayer' object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094310#M62215</link>
      <description>&lt;P&gt;i am trying to iterate the features from a feature service within ArcGIS Pro Notebook&lt;/P&gt;&lt;P&gt;this is my code and it seems to connect to the feature service and returns the name correctly&lt;/P&gt;&lt;LI-CODE lang="python"&gt;items = gis.content.search('title:LiveData owner:xxxxxx', 'feature layer')
OP1item = items[0]
PLS = OP1item.layers[11]
print(PLS.properties["name"])&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;xxSection&lt;/LI-CODE&gt;&lt;P&gt;but when i try and iterate it&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for x in PLS:
    print(x)&lt;/LI-CODE&gt;&lt;P&gt;i get this error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
In  [35]:
Line 3:     for x in PLS:

TypeError: 'FeatureLayer' object is not iterable
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;any ideas what i'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 09:14:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094310#M62215</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2021-09-01T09:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: 'FeatureLayer' object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094311#M62216</link>
      <description>&lt;P&gt;You can't iterate FeatureLayers. Create a SearchCursor and iterate that:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fields = [f.name for f in arcpy.ListFields(PLS)] # or define a subset of fields
print(fields)
with arcpy.da.SearchCursor(PLS, fields) as cursor:
    for row in cursor:
        print(row)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Sep 2021 09:26:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094311#M62216</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-01T09:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: 'FeatureLayer' object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094312#M62217</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;i tried that but got a different error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
In  [39]:
Line 3:     fields = [f.name for f in arcpy.ListFields(PLS)] # or define a subset of fields

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py, in ListFields:
Line 1134:  return gp.listFields(dataset, wild_card, field_type)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in listFields:
Line 353:   self._gp.ListFields(*gp_fixargs(args, True)))

OSError: "&amp;lt;FeatureLayer url:"https://xxx.xxx.xxx.net/arcgis/rest/services/Collector/LiveData/FeatureServer/11"&amp;gt;" does not exist
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;i also tried it with all fields and got another error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(PLS, "*") as cursor:
    for row in cursor:
        print(row)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
In  [40]:
Line 5:     with arcpy.da.SearchCursor(PLS, "*") as cursor:

RuntimeError: 'in_table' is not a table or a featureclass
---------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its got me stumped as i've iterated over feature layers in an AGOL Notebook in a similar way and it worked&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 09:37:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094312#M62217</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2021-09-01T09:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: 'FeatureLayer' object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094314#M62218</link>
      <description>&lt;P&gt;Example&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gdb = r"C:\arcpro_npg\npg\Project_npg\tests.gdb" 
arcpy.env.workspace = gdb
fcs = arcpy.ListFeatureClasses()
nmes = [i for i in fcs]

# take the first 3 fcs as an example
for i in fcs[:3]:
    fc = "\\".join([gdb, i])
    fnames = arcpy.ListFields(fc)
    flds.append([j.name for j in fnames])
    

nmes[:3]
['big', 'odd', 'odd_inters']

flds
['OBJECTID',
 'Shape',
 'Shape_Length',
... snip
 'PART_COUNT_1',
 'PNT_COUNT_1',
 ['OBJECTID', 'Shape', 'Shape_Length', 'Shape_Area'],
 ['OBJECTID',
  'Shape',
  'ORIG_FID',
.... snip
  'INSIDE_Y_1',
  'PART_COUNT_1',
  'PNT_COUNT_1']]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Sep 2021 10:10:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094314#M62218</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-09-01T10:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: 'FeatureLayer' object is not iterable</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094316#M62219</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've managed to get it working&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gis = GIS("home")
xxM = gis.content.get("54e2xxxeae")
xxLive = xxM.layers[11]&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;NewxxLive = xxLive.query(where = "OBJECTID = 11")&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;print("--Start Run--")
for feature in NewxxLive:
    print("---Start--")
    print(feature)
    print("----")&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;--Start Run--
---Start--
{"geometry": {"paths": [[[51....]]]}, "attributes": {"OBJECTID": 11 }}
----&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Sep 2021 10:49:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-featurelayer-object-is-not-iterable/m-p/1094316#M62219</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2021-09-01T10:49:36Z</dc:date>
    </item>
  </channel>
</rss>

