Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reading a file on python returns an empty string

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

  1. change f.readlines() to file.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.
  2. As you say the file size is 4TB, This could be the problem because of Max File Size In Python
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading