-
-
Save davewilton/d43d8e0b94f476981904c4a41e42a34c to your computer and use it in GitHub Desktop.
This file contains 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
# 1. Import modules: | |
import arcpy | |
from arcpy import env | |
import os | |
# 2. Set Parameters: | |
env.workspace = arcpy.GetParameterAsText(0) | |
option = arcpy.GetParameterAsText(1) | |
outputFilePath = arcpy.GetParameterAsText(2) | |
# 3. List of options as listed in the parameters: | |
dsList = [] | |
if option == "List Feature Classes": | |
featureclasses = arcpy.ListFeatureClasses() | |
for fc in featureclasses: | |
dsList.append(fc) | |
elif option == "List Tables": | |
tables = arcpy.ListTables() | |
for tables in table: | |
dsList.append(table) | |
elif option == "List Rasters": | |
rasters = arcpy.ListRasters() | |
for raster in rasters: | |
dsList.append(raster) | |
elif option == "List Workspaces": | |
workspaces = arcpy.ListWorkspaces() | |
for workspace in workspaces: | |
dsList.append(workspace) | |
elif option == "List Files": | |
files = arcpy.ListFiles() | |
for fl in files: | |
dsList.append(fl) | |
# 4. Write to outputFile (as a csv) and close | |
f = open(outputFilePath, 'w') | |
f.write("ID,OBJECT") | |
i = 1 | |
for item in dsList: | |
f.write("\n" + str(i) +"," + item) | |
i += 1 | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment