Last active
April 19, 2017 09:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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