How to check whether a file is empty or not?


Question

I have a text file.
How can I check whether it's empty or not?

1
232
7/30/2018 6:24:43 PM

Accepted Answer

>>> import os
>>> os.stat("file").st_size == 0
True
289
12/7/2014 9:22:19 PM

import os    
os.path.getsize(fullpathhere) > 0

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon