Skip to content

Instantly share code, notes, and snippets.

Created April 12, 2016 00:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# 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:
elif option == "List Tables":
tables = arcpy.ListTables()
for tables in table:
elif option == "List Rasters":
rasters = arcpy.ListRasters()
for raster in rasters:
elif option == "List Workspaces":
workspaces = arcpy.ListWorkspaces()
for workspace in workspaces:
elif option == "List Files":
files = arcpy.ListFiles()
for fl in files:
# 4. Write to outputFile (as a csv) and close
f = open(outputFilePath, 'w')
i = 1
for item in dsList:
f.write("\n" + str(i) +"," + item)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment