I have a very big file 4GB and when I try to read it my computer hangs. So I want to read it piece by piece and after processing each piece store the processed piece into an
To process line by line, this is an elegant solution:
def stream_lines(file_name): file = open(file_name) while True: line = file.readline() if not line: file.close() break yield line
As long as there're no blank lines.