I have a folder, with 1000s of txt files. My code is working perfectly fine if there is data in the file.
Is there anyway to build logic in my code to check if the file is empty, and if empty to skip to the next one?
import glob
import os
path = 'path/to/file'
for filename in glob.glob(os.path.join(path, '*.txt')):
with open(filename, 'r',encoding='ISO-8859-1') as f:
print(filename)
text = f.read()
do other stuff