#🔒 Python says file isn't readable despite the file being readable
33 messages · Page 1 of 1 (latest)
@still belfry
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Error:
Traceback (most recent call last):
File "c:\Users\***\OneDrive\Documents\python project 2025\Summer Programming Assignment 2025.py", line 91, in <module>
list_check()
File "c:\Users\***\OneDrive\Documents\python project 2025\Summer Programming Assignment 2025.py", line 30, in list_check
print(g.read())
^^^^^^^^
io.UnsupportedOperation: not readable
I'm not an expert or anything but try removing the +
Code:
from datetime import datetime # allows additional metadata for user entries in all categories
import time # might need it. loading screens are cool if nothing else!u = open("userdata.txt", "w") # user information for a personalised experience
f = open("food.txt", "w") # attempting to create save data per category for later checks.
g = open("transport.txt", "w")
j = open("utilities.txt", "w")
k = open("entertainment.txt", "w")
l = open("misc.txt", "w") # note to self: create option to clear save filesnow = datetime.now()
current_time = now.strftime("%D/%M/%Y %H:%M:%S")
n = 0
category_check = False
running = Truedef list_check():
print("1) Food\n 2) Transport\n 3) Utilities\n 4) Entertainment\n 5) Miscellaneous/Other")
while category_check == False:
checkcategory = int(input("Which category would you like to check?: "))
if checkcategory >= 6 or checkcategory <= 0:
time.sleep(1)
print("Please enter a valid number")
else:
if checkcategory == 1:
with open('food.txt', 'r+') as file:
print(f.read())
elif checkcategory == 2:
with open('transport.txt', 'r+') as file:
print(g.read())
elif checkcategory == 3:
with open('utilities.txt', 'r+') as file:
print(j.read())
elif checkcategory == 4:
with open('entertainment.txt', 'r+') as file:
print(k.read())
else:
with open('misc.txt', 'r+') as file:
print(l.read())
tried, the mode isnt affecting it so long as it encompasses reading permissions
i've tried read-only, append and read, write and read, etc
Is it in the same directory/does the program have permission to read it?
Hmm
Maybe instead of g put file
how would i check?
Just go to your File explorer and verify that both files are in the same directory
there wasnt anything there
i'll try it again real quick now that ive made the files
nothing
Hmm
Try this
possibly
its not writing to the file either
ive just done a test entry and nothing
Using this?
That's good
but now its just asking the prompt over and over again
i probably just need to write an exit method
Yeah probably
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.