Python Language Pedia
ItemCount Result For:
How to get line count cheaply in Python?
I need to get a line count of a large file (hundreds of thousands of lines) in python. What is the most efficient way both memory- and time-wise? At the moment I do: def file_len(fname): with open(fname) as f: for i, l in enumerate(f): ...
Page 1 of 1