How to skip files that have no data in them in folder? : <p>I have a folder, with 1000s of txt files. My code is working perfectly fine if there is data in the file. </p>

<p>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? </p>

<pre><code>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
</code></pre>
