Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Write a list of personal geodatabase feature classes to a CSV file
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment