I have been trying to read a file in python, the thing is that it returns an empty string. Here is the code:
with open('data.txt') as file:
content = f.readlines()
print(content) #prints nothing
note: It’s a really big file, is that a problem?
>Solution :
- change
f.readlines()tofile.readlines()This is only a typo. But I don’t know why you don’t get the error here. I think you open another file as f And You get the empty string here ’cause if you try to read a file more than once, you got an empty string except for the first time. - As you say the file size is
4TB, This could be the problem because ofMax File Size In Python