by

Write a list of personal geodatabase feature classes to a CSV file

Write a list of personal geodatabase feature classes to a CSV file: 
gdbList2csv.py
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/163571/Write-a-list-of-personal-geodatabase-fea?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
import csv, arcpy from arcpy import env # set path using raw string to personal geodatabase env.workspace = r"c:\users\mdiener\documents\mypersonalgeodatabase.gdb" # create a python list of all datasets in personal geodatabase datasetList = arcpy.ListDatasets('*','Feature') # open a file for writing. filename = r'c:\users\mdiener\documents\demo.csv' #open create new csv file with open(filename, 'wb') as myfile: wr = csv.writer(myfile,quoting=csv.QUOTE_ALL) for dataset in datasetList: env.workspace = dataset fcList = arcpy.ListFeatureClasses() print(fcList) # uncomment this if you want the csv all in one line # if not use code as is # wr.writerow(fcList) for each_fs in fcList: wr.writerow(each_fs.split(",")) print (each_fs)
If you want to be updated about similar snippets, Sign in and follow our Channels