Python - Processing Large Text Files One Line At A Time
fh = open('foo.txt', 'r') line = fh.readline() while line: # do something here line = fh.readline()
// Update
for line in open('foo.txt', 'r'): # do something here
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
fh = open('foo.txt', 'r') line = fh.readline() while line: # do something here line = fh.readline()
for line in open('foo.txt', 'r'): # do something here