I'm very new to python and have created a script for enabling a user to list file types in a workspace making use of the parameters function in ArcGIS so it's more user friendly. However I cannot get the script to work...I am struggling to finish the script off can anyone lend a hand?
Python reports the syntax error in line 36 "f.close()" there is no white space around it so am struggling to see whats wrong...can you? Or what am I missing?
Here's the code:
import arcpy
from arcpy import env
import os
env.workspace = ("C:\ArcGIS\Default.gdb")
ws = arcpy.GetParameter(0)
option = arcpy.GetParameterAsText(1)
outputFilePath = arcpy.GetParameterAsText(2)
dsList = []
if option == "List Feature Classes":
featureclasses = arcpy.ListFeatureClasses(ws)
for table in tables:
dsList.append(table)
elif option == "List Tables":
tables = arcpy.ListTables(ws)
for table in tables:
dsList.append(table)
elif option == "List Rasters":
rasters = arcpy.ListRasters(ws)
for table in tables:
dsList.append(table)
elif option == "List Workspaces":
workspaces = arcpy.ListWorkspaces(ws)
for table in tables:
dsList.append(table)
elif option == "List Files":
files = arcpy.ListFiles(ws)
for table in tables:
dsList.append(table)
f = open(outputFilePath, 'w')
for item in dsList:
f.close()