Skip to content

Instantly share code, notes, and snippets.

@AnthonyDiGirolamo
Last active December 16, 2019 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnthonyDiGirolamo/9665403 to your computer and use it in GitHub Desktop.
Save AnthonyDiGirolamo/9665403 to your computer and use it in GitHub Desktop.
How to read a file in python line by line. This method incrementally loads the file.
#!/usr/bin/env python
#import pprint
#pp = pprint.PrettyPrinter(indent=4, width=110).pprint
with open('all_messages.log') as f:
for i, line in enumerate(f):
print("{0}:".format(i), end='')
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment