Answer the question
In order to leave comments, you need to log in
It turns out an error. What to do?
What should I do?
here is the code:
import openpyxl
from openpyxl import Workbook
date = '333'
prih = int(input())
toilet = int(input())
van = int(input())
dataFile = open('log.txt', 'r')
last_line = dataFile.readlines()[-1]
dataFile.close()
wb = openpyxl.reader.excel.load_workbook(filename='pok.xlsx', data_only=True)
wb.active = 0
sheet = wb.active
sheet['A' + last_line] = date
sheet['B' + last_line] = prih
sheet['C' + last_line] = toilet
sheet['D' + last_line] = van
wb.save('pok.xlsx')
startfile("pok.xlsx")
writeFile = open('log.txt', 'a')
aa = int(last_line) + 1
writeFile.write('\n' + str(aa))
writeFile.close()
Traceback (most recent call last):
File "C:/Users/vayak/PycharmProjects/pythonProject6/main.py", line 17, in <module>
wb.save('pok.xlsx')
File "C:\Users\vayak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\openpyxl\workbook\workbook.py", line 392, in save
save_workbook(self, filename)
File "C:\Users\vayak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\openpyxl\writer\excel.py", line 291, in save_workbook
archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1520.0_x64__qbz5n2kfra8p0\lib\zipfile.py", line 1251, in __init__
self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'pok.xlsx'
Answer the question
In order to leave comments, you need to log in
Based on the error, access to the file is denied, did you close the file before running the script?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question