FileNotFoundError: [Errno 2] No such file or directory Pandas
Question:
Answers:
I think you can modify the code by writing it in this way:
pd.read_excel("./<file name>")
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:UsersselmanPycharmProjectsselman_learningbisiklet_fiyatlari.xlsx")
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)
import pandas as pd
path = 'absolute_path/records.xlsx' #eg. C:\Projects\readexcel\file\records.xlsx
df = pd.read_excel(path)
Do the above
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'))
‘pathtoexcel_file.xlsx’ should be the relative path to the .xlsx from the project root.
Credit to this answer to a similar question.
I think you can modify the code by writing it in this way:
pd.read_excel("./<file name>")
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:UsersselmanPycharmProjectsselman_learningbisiklet_fiyatlari.xlsx")
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)
import pandas as pd
path = 'absolute_path/records.xlsx' #eg. C:\Projects\readexcel\file\records.xlsx
df = pd.read_excel(path)
Do the above
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'))
‘pathtoexcel_file.xlsx’ should be the relative path to the .xlsx from the project root.
Credit to this answer to a similar question.