Home » excel » Python read issue in excel with pandas

Python read issue in excel with pandas

Posted by: admin May 14, 2020 Leave a comment


Hi I am new to the open source tech – I am using Anaconda3-5.1.0-Windows-x86_64 & Microsoft Excel 2016.The Excel reading operation using pandas throws error as File not found error for the below code.

import pandas as pd 
from pandas import ExcelWriter 
from pandas import ExcelFile 
path= "D:\sample.xlsx" 
df = pd.read_excel(path, sheet_name = 'Sheet1') 
print('Column headings:') 

The error message is FileNotFoundError: [Errno 2] No such file or directory: ‘D:\sample.xlsx’-

I was trying to read ‘D:\sample.xlsx’ but the function tries to open file as ‘D:\sample.xlsx’.

Can anyone please advise on this issue or shall let me know any more details required.

How to&Answers:


path= "D:\sample.xlsx"


path= r"D:\sample.xlsx" or path= "D:\sample.xlsx"