I am having some issues with the below code:
with open(".../file.txt", encoding="utf-8", errors="ignore") as f:
data = f.read()
I have a particular txt
file of size 2.5GB and am trying to read it into my 16GB of RAM. However, after only a second or two, Python seems to be using 100% of my RAM and I get a memory error. The exact same code works as intended for other files. What can I do to investigate this?
EDIT
Actually, it appears as if Windows is lying about its file size... The file's proprties tab indicates 2.5GB but when loading it into the WordPad text editor, it was also progressively reading data into memory and beyonf the size indicated by Windows. Any thoughts?