Skip to content

Instantly share code, notes, and snippets.

@pwldp
Last active April 19, 2017 09:06
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 pwldp/7541bcd026e6726eb104ff85b5071310 to your computer and use it in GitHub Desktop.
Save pwldp/7541bcd026e6726eb104ff85b5071310 to your computer and use it in GitHub Desktop.
Read large text files in Python, line by line without loading it in to memory
with open( filePath ) as infile:
"""
# read first line and remember it
first_line = infile.readline()
# or only skip first line
next( infile )
"""
for line in infile:
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment