We have a list of feature-classes which are in multiple gdb's in multiple folders. This code is opening the csv and doing "GetCount_management" for the listed feature_classes alone and printing the output. The code is printing correctly. Say, if there are 25 feature classes in the csv, it's listing all the counts of all the 25 files. But while saving it in csv, only the 25th count i.e the last file's count alone is getting saved. I don't know whats the issue.
import csv import arcpy from os import path csvpath = r"D:\RTXQAQC\Open2.csv" output = r'D:\Test\Test_2.csv' csvdir = path.split(csvpath) with open(csvpath, "r") as csvfile: fcs = [r for r in csv.reader(csvfile)] for fc in fcs: result = arcpy.GetCount_management(fc) count = int(result.getOutput(0)) print(count) with open(output, 'wb') as f: csvwriter = csv.writer(f,delimiter=',') csvwriter.writerow([fc,result]) f.close()