Reputation: 320
I am trying to read my excel file with pd.read_excel in python. But ı am get this error message = FileNotFoundError: [Errno 2] No such file or directory
I put my excel file same place with my python file. pic1 pic2
Upvotes: 1
Views: 37047
Reputation: 57
Providing the absolute path to the .xlsx file worked for me. For situations where you cannot anticipate what the absolute path will be, try the following:
import os.path
pd.read_excel(io=os.path.abspath('path\\to\\excel_file.xlsx'))
'path\to\excel_file.xlsx' should be the relative path to the .xlsx from the project root.
Credit to this answer to a similar question.
Upvotes: 0
Reputation: 471
You can use full path this way to read the excel file. And also add r
prefix before the file path so backslash will be treated as literal character
pd.read_excel(r"C:\Users\selman\PycharmProjects\selman_learning\bisiklet_fiyatlari.xlsx")
Upvotes: 2
Reputation: 180
I think you can modify the code by writing it in this way:
pd.read_excel("./<file name>")
Upvotes: 0
Reputation: 135
import pandas as pd
path = 'absolute_path/records.xlsx' #eg. C:\\Projects\\readexcel\\file\\records.xlsx
df = pd.read_excel(path)
Do the above
Upvotes: 1
Reputation: 11
I think you need to put file object and not only the path of the file. Try to use:
with open("<path to your file>", encoding = 'utf-8') as f:
pandas.read_excel(f)
Upvotes: 0