I am trying to modify existing excel file on Windows using Python via Pandas, but the program gives me an error.
This is a sample of my simple program:
df_read = pd.read_excel("C:\\Users\\77888\\Desktop\\HKR_ОТЧЕТЫ\\Ноябрь 2020\\2020-11-03.xlsx")
df = pd.DataFrame({"Время":[1], "Сумма счета":[1], "Столы":[1], "Заказ":[1]})
df = df.append({"Время":1, "Сумма счета":1, "Столы":1, "Заказ":1}, ignore_index = True)
path = "C:\\Users\\77888\\Desktop\\HKR_ОТЧЕТЫ\\Ноябрь 2020\\2020-11-03.xlsx"
assert os.path.isfile(path)
writer = pd.ExcelWriter(path, engine = 'xlsxwriter')
writer.save()
Here is the error: Traceback (most recent call last): File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\site-packages\xlsxwriter\workbook.py", line 320, in close self._store_workbook() File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\site-packages\xlsxwriter\workbook.py", line 638, in _store_workbook raise e File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\site-packages\xlsxwriter\workbook.py", line 635, in _store_workbook xlsx_file = ZipFile(self.filename, "w", compression=ZIP_DEFLATED, File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\zipfile.py", line 1239, in init self.fp = io.open(file, filemode) PermissionError: [Errno 13] Permission denied: 'C:\Users\77888\Desktop\HKR_ОТЧЕТЫ\Ноябрь 2020\2020-11-03.xlsx'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\77888\Desktop\HKR_ОТЧЕТЫ\check.pu", line 12, in writer.save() File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel_xlsxwriter.py", line 193, in save return self.book.close() File "C:\Users\77888\AppData\Local\Programs\Python\Python39\lib\site-packages\xlsxwriter\workbook.py", line 322, in close raise FileCreateError(e) xlsxwriter.exceptions.FileCreateError: [Errno 13] Permission denied: 'C:\Users\77888\Desktop\HKR_ОТЧЕТЫ\Ноябрь 2020\2020-11-03.xlsx' [Finished in 1.531s]
ExcelWriter(path, engine = 'xlsxwriter', mode= ‘a’)
– Petronella