Python Forum

Full Version: Simple Read File Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
So basically i'm trying to read something from a simple text file, and i don't really get any errors but the output is blank. Any help is appreciated :-)

employee_file = open("asa.txt", "r")

print(employee_file.read())

employee_file.close()
Output:
Process finished with exit code 0
maybe the text file is empty?
It's not...

Dammit i guess it's a unique problem only on my computer, i have tried with 3 diffrent text files, still same result.. Also i have tried to "r+" and "w" still..
Did you start the script in the same directory that contains the text file?

You can try the full path

employee_file = "/Path/To/asa.txt"
with open(employee_file, 'r') as f:    
    print(f.read())
I just fixed it :D. The problem was with the software and not the actual code. I do not know why?? But after installing Submlime Text everything worked perfectly fine, i used PyCharm before. So weird... It should work either way. Thank u so much for trying to help.