Reputation: 70
i am having this issue since like 2 months, it didnt bother me at first but now that im trying to import a file with pd or even a normal txt file with open()
it gives me this Exception:
File "C:\Users\lcc_zarkos\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\common.py", line 642, in get_handle
handle = open(
FileNotFoundError: [Errno 2] No such file or directory: 'marketing.xlsx'
if i use the full path it just runs normally. people would say "just use full path then" but this is a really bad solution when it comes to using this program on multiple devices with different paths or stuff like that so i hope you have any solutions. here is the code:
import pandas as pd
df = pd.read_csv('marketing.xlsx')
edit: it has none to do with the code itself but more like windows or my pc
Upvotes: 0
Views: 6702
Reputation: 3158
i see a spaces in the file name there. I tried on mac, and it works very well. ['main.py', 'marketing .xlsx', 'requirements.txt']
Upvotes: 0
Reputation: 1362
FileNotFoundError
means that the file path you've given to pandas point to an non existing file.
In your case this can be caused by:
In both case, I would print the file path, and check the location using a file browser, you will find your mistake:
print(os.path.join(os.getcwd(), 'marketing.xlsx'))
Upvotes: 1