memory - Why does Python produce a MemoryError when I open this file -
i trying remove empty lines file. method reading file line line , writing lines not newlines new file. works great small files, reasons don't understand, i'm getting memoryerror on larger ones. problem file on 1gb, since i'm reading line line, don't think i'm storing more 1 line in memory. or i?
with open(output_path, "ab+") out_file: open(input_path, "rb") in_file: line = in_file.readline() while line: if line != "\n": out_file.write(line) line = in_file.readline()
when split file chunks, works fine, that's step i'd rather not do. want understand happening here. thanks!
it turns out problem elsewhere in code. wasn't explicitly closing file, led issue. help.
Comments
Post a Comment