Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdiener21/894209e96d37165b9d16 to your computer and use it in GitHub Desktop.
Save mdiener21/894209e96d37165b9d16 to your computer and use it in GitHub Desktop.
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