Never been to CodeSnippets before?

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!)

1 total

Python - Processing Large Text Files One Line At A Time

// process some very 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
1 total