Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to know how much lines a file has using python

filename = "test.txt"
count = 0
with open(filename, 'r') as f:
    for line in f:
        count += 1
print("Total number of lines is:", count)
Comment

PREVIOUS NEXT
Code Example
Python :: print underline text python 
Python :: python plot jpg image 
Python :: get all indices of a value in list python 
Python :: kivy date widget 
Python :: pydotprint 
Python :: Replace empty string and "records with only spaces" with npnan pandas 
Python :: time track python 
Python :: select only object columns pandas 
Python :: how to rearrange list in python 
Python :: python for property in object 
Python :: sklearn adjusted r2 
Python :: add a dot in a long number in python 
Python :: # list all keywords in Python 
Python :: check if a value in dataframe is nan 
Python :: Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory. 
Python :: python convert base 
Python :: bulk file name changer in python 
Python :: python program to give shop name 
Python :: pandas row number by group 
Python :: python sort dataframe by one column 
Python :: scikit learn linear regression 
Python :: how to filter out all NaN values in pandas df 
Python :: ssl unverified certificate python 
Python :: sqlalchemy delete by id 
Python :: create folder python 
Python :: tkinter text in canvas 
Python :: how to check if a message includes a word discord.py 
Python :: exclude columns in df 
Python :: install log21 python 
Python :: reset index 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =