I often download data that comes in 30 minutes to 1-hour windows and then have to compile that data manually into one feature class, from multiple GDBs. I am trying to iterate through the separate GDBs and store each point feature class in an object. Here's what I have so far (Python 2.7.14):

import arcpy
import os
from arcpy import env
outputOverwrite = True


arcpy.env.workspace = r'C:\Vector\20190902'
print('ws set')

workspaces = arcpy.ListWorkspaces(workspace_type = 'FileGDB')

for workspace in workspaces:
   datasets = arcpy.ListDatasets(feature_type = 'All')

for ds in datasets:
   arcpy.env.workspace = ds
   fc = arcpy.ListFeatureClasses(feature_type = 'Point')

I am unable to post pictures or copy and paste my code, as the system is on a totally different network.

Edited to reflect changes made by @BERA.

This code outputs

ws set

It doesn't print the feature classes like i expected it to.

I traced this back to the line of code

for workspace in workspaces:
    datasets = arcpy.ListDatasets(feature_type='All')

When I tried to do


It gave me blank lists


Hope this clears up the ambiguity on my end.

  • Just sat back down. Typing in that addition now. Logically to me, next step is just merging the stored fcs to a common gdb. – cameron Sep 2 '19 at 8:20

ListFeatureClasses will search in current workspace, which is r'C:\Vector\20190902'. You need to change it to point at each gdb when listing feature classes.

I dont know why you are listing datasets, are you sure that is what you want?

If you have a structure like this, code below will work: enter image description here

import arcpy, os

arcpy.env.workspace = r'C:\GIS\ArcMap_default_folder'

fclist = []
for ws in arcpy.ListWorkspaces(workspace_type='FileGDB'):
    arcpy.env.workspace = ws
    for fc in arcpy.ListFeatureClasses(feature_type='POINT'):
        fclist.append(os.path.join(ws, fc))

print (fclist)

['C:\\GIS\\ArcMap_default_folder\\Default.gdb\\point1', 'C:\\GIS\\ArcMap_default_folder\\test.gdb\\point2']
  • Something was wrong with what I have earlier. When I went to go plug in the first piece of code you went to help me with, it wouldn't print the fcs. I'm pretty sure it has something to do with when i store the datasets as an object. I went to print the datasets and it gave me an empty list. – cameron Sep 2 '19 at 8:32
  • Edited the code to reflect the current state. Am unable to upload pictures of the data structure or code, as the system is on a completely different network, and is unable to communicate with the one im currently on. – cameron Sep 2 '19 at 9:57
  • 1
    Yessir (or ma'am), that was the answer that I was looking for. I thought to access the feature class in each geodatabase, you first had to open/store each dataset in the geodatabase. Thank you so much for your help! – cameron Sep 2 '19 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.