Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python 3 text file leng

f = open("filename", "r") #Load file in any mode that's able to read, ie r, r+, w+ etc

#to get length
len(f.readlines())

#To iterate over each line
for line in f.readlines(): #file.readlines(), splits the file into a list, where each element is a seperate line
  print(line)
Comment

PREVIOUS NEXT
Code Example
Python :: python get line number of error 
Python :: how to add legend to python plot 
Python :: Pandas: How to Drop Rows that Contain a Specific String 
Python :: selenium press tab python 
Python :: colab save figure 
Python :: python capture exception 
Python :: pandas find na 
Python :: gdscript string format 
Python :: python pandas change or replace value or cell name 
Python :: extract domain name from url python 
Python :: pandas calculate iqr 
Python :: drop unnamed column pandas 
Python :: how to center plotly plot title 
Python :: hibernate windows with python 
Python :: migrate skip in django 
Python :: ipykernel pip 
Python :: track phone number location using python 
Python :: python reload class 
Python :: export file csv 
Python :: selenium driver wait python 
Python :: checking django version 
Python :: print colored text python 
Python :: spammer bot python 
Python :: python read file line by line 
Python :: Can only use .dt accessor with datetimelike values 
Python :: absolute value columns pandas 
Python :: plot roc curve for neural network keras 
Python :: youtube dl download mp3 python 
Python :: how copy and create same conda environment 
Python :: pandas groupby column count distinct values 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =