Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

counting number of lines in a text file in python

# You can do it by iterating through a simple for loop
fhand = open('path and the file name')
count = 0
for line in fhand:
  count += 1
print('The number of lines in the file is:', count)
Source by www.py4e.com #
 
PREVIOUS NEXT
Tagged: #counting #number #lines #text #file #python
ADD COMMENT
Topic
Name
9+4 =