Skip to content

Instantly share code, notes, and snippets.

@davewilton
Created April 12, 2016 00:44
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 davewilton/d43d8e0b94f476981904c4a41e42a34c to your computer and use it in GitHub Desktop.
Save davewilton/d43d8e0b94f476981904c4a41e42a34c to your computer and use it in GitHub Desktop.
# 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