3 Replies Latest reply on Apr 27, 2012 8:32 AM by stevenmw

    need help with looping through .mdb, feature datasets, feature classes.

    stevenmw
      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.  I am running this code and it is only returning the last feature dataset in the list.  It is returning the list of folders, mdbs, but only the very last feature dataset and feature class.  What do I need to change in my code so that it returns all of the feature datasets and feature classes?  Any help is appreciated.


      import arcpy
      arcpy.env.workspace = "X:"
      ws = arcpy.ListWorkspaces("*","Folder")
      
      for w in ws:
          arcpy.env.workspace = w 
          gdb = arcpy.ListWorkspaces("*", "Access")
          
      
      for fc in arcpy.ListWorkspaces("*", "Access"):
          arcpy.env.workspace = fc
          fcl = arcpy.ListDatasets("*", "Feature")
      
      for fcc in arcpy.ListDatasets("*", "Feature"):
          arcpy.env.workspace = fcc
          fccl = arcpy.ListFeatureClasses("*", "All")
          print fccl
          


      Here is the output:

      [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&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']


      [u'X:\\St_Stephens\\stste.mdb']
      [u'X:\\Summerton_GQM6\\summe.mdb']
      [u'X:\\SummervilleNW\\sumnw.mdb']
      [u'X:\\Sunset_GQM28\\sunse.mdb']
      [u'X:\\Swansea_OFR40\\swans.mdb']
      [u'X:\\Table_Rock_GQM9\\tablr.mdb']
      [u'X:\\Taxahaw_OFR5\\taxah.mdb']
      [u'X:\\Taylors_OFR133&134\\taylo.mdb']
      [u'X:\\Tigerville_GQM45\\tiger.mdb']
      [u'X:\\Tillman\\tillm.mdb']
      [u'X:\\Trenton\\trent.mdb']
      [u'X:\\Tugaloo_Lake_OFR156\\tugal.mdb']
      [u'X:\\Tybee\\tyino.mdb']
      [u'X:\\Unity\\Unity.mdb']
      [u'X:\\Valley_Falls_OFR96\\vallf.mdb']
      [u'X:\\Vance\\vance.mdb']
      [u'X:\\Van_Wyck\\VanWyck.mdb']
      [u'X:\\Wagener\\wagen.mdb']
      [u'X:\\Ware_Shoals_East_GQM12\\wasea.mdb']
      [u'X:\\Ware_Shoals_West_GQM26\\waswe.mdb']
      [u'X:\\Wateree_GQM36\\watee.mdb']
      [u'X:\\Waterloo_OFR82\\watlo.mdb']
      [u'X:\\Waxhaw\\Waxhaw.mdb']
      [u'X:\\Wedgefield_GQM47\\wedge.mdb']
      [u'X:\\Wellford_OFR95\\wellf.mdb']
      [u'X:\\Whetstone_OFR155\\whets.mdb']
      [u'X:\\Wiggins_GQM18\\wiggi.mdb']
      [u'X:\\Williston_OFR75\\wills.mdb']
      [u'X:\\Windsor_OFR90\\winds.mdb']
      [u'X:\\Woodruff_OFR121\\woodr.mdb']
      [u'X:\\Zirconia_GQM39\\zirco.mdb']
      [u'zirco']
      [u'zircoa_1', u'zircop_1', u'zircol_1']