Can't read a .xlsx/.csv file while I have it open in my Excel

Viewed 33

I got that error everytime I try to read a .xlsx/.csv file in my Jupyter Notebook using Pandas and the file is currently open in my Excel:

import pandas as pd

df = pd.read_excel('Filename.xlsx')
PermissionError: [Errno 13] Permission denied: 'Filename.xlsx'

I have a friend that could read those files in his Jupyter without closing the Excel. How can I make it?

1 Answers

close all your open excel/csv files then try to read the file.

For csv files:

import pandas as pd

df = pd.read_csv('filename.csv')

For excel file:

pip install xlrd

import pandas as pd

df = pd.read_excel('filename.xlsx')
Related