I have a huge .txt file containing approx 100m lines, and I want to save its content into a list line by line.
I'm using the following code to achive this:
tmp=[]
with open('xy.txt') as f:
for line in f:
tmp.append(line)
Now the problem with this, that this code doesn't release the memory until the whole file is read, thus after a while it runs out of memory.
My question is, that is there any way of completing this task memory efficiently?