+ 10
How to read line by line from 4GB txt file with out loading the whole file to RAM??
in python
7 Respuestas
+ 7
I mean how can I read more than 600 line with out memory load or error
+ 7
i need to make my code to keep the whole file itself rather to read a line in a time, process it then reads the second line and so on
+ 6
How do you even get a 4GB txt file?
+ 6
try this perhaps?
from:
https://stackoverflow.com/questions/6475328/read-large-text-files-in-JUMP_LINK__&&__python__&&__JUMP_LINK-line-by-line-without-loading-it-in-to-memory
import fileinput
for line in fileinput.input("filename"):
process(line)
OR
with open("log.txt") as fileobject:
for line in fileobject:
do_something_with(line)
+ 3
maybe readline() method
+ 3
This time i send you a link https://www.ibm.com/developerworks/library/x-hiperfparse/