<?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: need help with looping through .mdb, feature datasets, feature classes. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117822#M9243</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Ok, so basically Im trying to loop through all of my folders, mdbs, feature datasets, and feature classes in order use the SearchCursor to read values in the feature classes attribute table.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a nice example in the online help here (bottom of the article) that shows the indentation and setting the workspaces correctly. If you started with this example it may be worth another look. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z00000011000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Arc 10.0 help: Listing data&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing I see you're doing is listing things more than once, the list functions return a list which you can then iterate over, your code seems to try to generate another list instead of using the one you just created.... here's a suggested approach:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for w in ws:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = w 
&amp;nbsp;&amp;nbsp;&amp;nbsp; gs = arcpy.ListWorkspaces("*", "Access")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for g in gs:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = g
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fds = arcpy.ListDatasets("*", "Feature")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fd in fds ...&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:54:46 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T06:54:46Z</dc:date>
    <item>
      <title>need help with looping through .mdb, feature datasets, feature classes.</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117820#M9241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, so basically Im trying to loop through all of my folders, mdbs, feature datasets, and feature classes in order use the SearchCursor to read values in the feature classes attribute table.&amp;nbsp; I am running this code and it is only returning the last feature dataset in the list.&amp;nbsp; It is returning the list of folders, mdbs, but only the very last feature dataset and feature class.&amp;nbsp; What do I need to change in my code so that it returns all of the feature datasets and feature classes?&amp;nbsp; Any help is appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
arcpy.env.workspace = "X:"
ws = arcpy.ListWorkspaces("*","Folder")

for w in ws:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = w 
&amp;nbsp;&amp;nbsp;&amp;nbsp; gdb = arcpy.ListWorkspaces("*", "Access")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

for fc in arcpy.ListWorkspaces("*", "Access"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = fc
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcl = arcpy.ListDatasets("*", "Feature")

for fcc in arcpy.ListDatasets("*", "Feature"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = fcc
&amp;nbsp;&amp;nbsp;&amp;nbsp; fccl = arcpy.ListFeatureClasses("*", "All")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fccl
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\St_Stephens', u'X:\\Summerton_GQM6', u'X:\\SummervilleNW', u'X:\\Sunset_GQM28', u'X:\\Swansea_OFR40', u'X:\\Table_Rock_GQM9', u'X:\\Taxahaw_OFR5', u'X:\\Taylors_OFR133&amp;amp;134', u'X:\\Tigerville_GQM45', u'X:\\Tillman', u'X:\\Trenton', u'X:\\Tugaloo_Lake_OFR156', u'X:\\Tybee', u'X:\\Unity', u'X:\\Valley_Falls_OFR96', u'X:\\Vance', u'X:\\Van_Wyck', u'X:\\Wagener', u'X:\\Ware_Shoals_East_GQM12', u'X:\\Ware_Shoals_West_GQM26', u'X:\\Wateree_GQM36', u'X:\\Waterloo_OFR82', u'X:\\Waxhaw', u'X:\\Wedgefield_GQM47', u'X:\\Wellford_OFR95', u'X:\\Whetstone_OFR155', u'X:\\Wiggins_GQM18', u'X:\\Williston_OFR75', u'X:\\Windsor_OFR90', u'X:\\Woodruff_OFR121', u'X:\\Zirconia_GQM39']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\St_Stephens\\stste.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Summerton_GQM6\\summe.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\SummervilleNW\\sumnw.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Sunset_GQM28\\sunse.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Swansea_OFR40\\swans.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Table_Rock_GQM9\\tablr.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Taxahaw_OFR5\\taxah.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Taylors_OFR133&amp;amp;134\\taylo.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Tigerville_GQM45\\tiger.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Tillman\\tillm.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Trenton\\trent.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Tugaloo_Lake_OFR156\\tugal.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Tybee\\tyino.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Unity\\Unity.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Valley_Falls_OFR96\\vallf.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Vance\\vance.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Van_Wyck\\VanWyck.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Wagener\\wagen.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Ware_Shoals_East_GQM12\\wasea.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Ware_Shoals_West_GQM26\\waswe.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Wateree_GQM36\\watee.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Waterloo_OFR82\\watlo.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Waxhaw\\Waxhaw.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Wedgefield_GQM47\\wedge.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Wellford_OFR95\\wellf.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Whetstone_OFR155\\whets.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Wiggins_GQM18\\wiggi.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Williston_OFR75\\wills.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Windsor_OFR90\\winds.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Woodruff_OFR121\\woodr.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'X:\\Zirconia_GQM39\\zirco.mdb']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'zirco']&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[u'zircoa_1', u'zircop_1', u'zircol_1']&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 12:27:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117820#M9241</guid>
      <dc:creator>StevenWorkman</dc:creator>
      <dc:date>2012-04-27T12:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: need help with looping through .mdb, feature datasets, feature classes.</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117821#M9242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Steven,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your main problem is your indentation in the Python code.&amp;nbsp; Your loops should be nested.&amp;nbsp; See a similar forum posting &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/55215-list-all-data-sources-used-in-MXD-or-batch-of-MXDs-in-a-text-file?p=189782#post189782"&gt;here.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cory&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 13:49:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117821#M9242</guid>
      <dc:creator>CoryMacNeil1</dc:creator>
      <dc:date>2012-04-27T13:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: need help with looping through .mdb, feature datasets, feature classes.</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117822#M9243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Ok, so basically Im trying to loop through all of my folders, mdbs, feature datasets, and feature classes in order use the SearchCursor to read values in the feature classes attribute table.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a nice example in the online help here (bottom of the article) that shows the indentation and setting the workspaces correctly. If you started with this example it may be worth another look. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z00000011000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Arc 10.0 help: Listing data&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing I see you're doing is listing things more than once, the list functions return a list which you can then iterate over, your code seems to try to generate another list instead of using the one you just created.... here's a suggested approach:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for w in ws:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = w 
&amp;nbsp;&amp;nbsp;&amp;nbsp; gs = arcpy.ListWorkspaces("*", "Access")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for g in gs:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = g
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fds = arcpy.ListDatasets("*", "Feature")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fd in fds ...&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117822#M9243</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T06:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: need help with looping through .mdb, feature datasets, feature classes.</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117823#M9244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Really appreciate the help you guys! Ill check back if I cant get this thing going.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 15:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-looping-through-mdb-feature/m-p/117823#M9244</guid>
      <dc:creator>StevenWorkman</dc:creator>
      <dc:date>2012-04-27T15:32:26Z</dc:date>
    </item>
  </channel>
</rss>

