File not found even though it is in the file is there

I am getting this error code. I have looked through here and did not find the answer. I know it means it can’t find the file but I have the file uploaded. I am just not sure how to tell if it is in the same directory as main.py.

Traceback (most recent call last):
File “/home/runner/Create-Task/main.py”, line 9, in
with open(‘CT information.csv’, ‘r’) as file:
FileNotFoundError: [Errno 2] No such file or directory: ‘CT information.csv’

Here is the link to my code.
https://replit.com/@smcgilvra1/Create-Task

Any help would be greatly appreciated.

Sharon

Hi @smcgilvra1 , welcome to the forums!
You should not use spaces in your file name. Instead, use underscores (_) or hyphens (-).
You will need to rename your file fom CT information.csv to CT_information.csv, and edit theopen() command to include the underscore:

with open('CT_information.csv', 'r') as file:
  # Rest of the code

Hope this helps!

1 Like

Thank you. I had done that but it was not before. I had to refresh my page and it worked.

What’s wrong with having a space in the filename?

IIRC the issue was spaces sometimes.

I think it’s because spaces are typically used to separate arguments, and if the spaces is not properly quoted the interpreter may misinterpret it as multiple arguments.

2 Likes