I have so many CSV files in a particular folder. So i just want to check which CSV file is empty and if any csv file is empty print that file name also. And Some files may be contain only header part. So this type file will also be empty file. I need to print that file also.
try:
path = '/nsmnt/NS_Exec_DSHBD/output/*.csv'
files = glob.glob(path)
for name in files:
with open(name, 'r') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
#print(row)
if row[0] == 'NULL':
print("file is empty!")
print(name)
except Exception as ex:
print(ex)