Last active
August 29, 2015 14:06
-
-
Save mdiener21/894209e96d37165b9d16 to your computer and use it in GitHub Desktop.
Write a list of personal geodatabase feature classes to a CSV file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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