I have prepared a Python code and I got the following errors:
"Parsing error IndentationError: expected an indented block (line 11)"
and
"Runtime error Traceback (most recent call last): File "",
line 10, in TypeError: 'NoneType' object is not iterable"
The purpose of the code is to list all feature datasets & feature classes from a single geodatabase into CSV.
import os
import csv
import arcpy
from arcpy import env
env.workspace = "I:\J_Prashant's External HD\High Speed Rail\Task from Greg Campbell\Layers\HST_BP_GIS_Data.gdb"
datasetList = arcpy.ListDatasets('*','Feature')
for dataset in datasetList:
arcpy.env.workspace = dataset
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
print arcpy.env.workspace,fc
csv_out = open('I:\\python\\List-Feature-Class\\test2.csv', 'wb')
mywriter = csv.writer(csv_out)
rows = zip(arcpy.env.workspace,fc)
mywriter.writerows(rows)
csv_out.close()
Best Answer
I think you should research/ask about writing to a CSV file separately at StackOverflow because the technique you are using to do that is pure Python rather than ArcPy.
For the remainder I think this should work (use a modification of your file geodatabase location where I have used C:\temp\test.gdb):
The two main issues were: