I have a database with multiple feature classes. Now I extracted a list of feature classes and a list of fields. I figured out how to write the list of feature classes and the corresponding fields to csv. But the csv file gets really long. Instead I would like to write each feature class name with the corresponding field names to a separate csv file. My code looks like this right now:
def csvwriter (csvfile, mylist):
myfile = open(csvfile,'ab')
wr = csv.writer(myfile)
wr.writerow(mylist)
datasets = arcpy.ListDatasets()
for ds in datasets:
dslist = []
dslist.append(ds)
csvwriter (csvfile1,dslist)
for fc in arcpy.ListFeatureClasses("*","",ds):
fclist = []
fclist.append(fc)
csvwriter(csvfile1,fclist)
for field in arcpy.ListFields(fc):
fieldlist = []
fieldlist.append(field.name)
csvwriter(csvfile1,fieldlist)