Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check if a file is empty

import os
if os.stat("yourfile.extension").st_size == 0:
#note: file has to be in same directory as python script#
  print('empty')
Comment

how to check if a file is empty using python

>>> import os
>>> os.stat("file").st_size == 0
True
Comment

PREVIOUS NEXT
Code Example
Python :: find all nan columns pandas 
Python :: python get newest file in directory 
Python :: pytorch tensor add one dimension 
Python :: python read file delete first line 
Python :: managin media django 
Python :: change directory in python os 
Python :: select closest number in array python 
Python :: change type of array python 
Python :: python duplicate file 
Python :: random gen in python 
Python :: pip install arcpy python 3 
Python :: python how to get number of strings in a list 
Python :: SSL: CERTIFICATE_VERIFY_FAILED with Python3 
Python :: how to receive password using tkinter entry 
Python :: export python pandas dataframe as json file 
Python :: Find the Runner Up Score solution in python3 
Python :: console clear python 
Python :: install magic python 2 
Python :: count nan pandas 
Python :: install flake8 python 
Python :: scroll to element python selenium 
Python :: python open new chrome tab 
Python :: string to time python 
Python :: how to pause code for some time in python 
Python :: valueerror expected 2d array got 1d array instead python linear regression 
Python :: RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() 
Python :: django gmail smtp 
Python :: how to install nltk 
Python :: edge driver selenium python 
Python :: chrome driver download for selenium python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =