Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python count empty lines in text file

with open('data.txt', 'r') as f:
    lines = f.readlines()
    num_lines = len([l for l in lines if l.strip(' 
') != ''])
Source by newbedev.com #
 
PREVIOUS NEXT
Tagged: #python #count #empty #lines #text #file
ADD COMMENT
Topic
Name
3+9 =