I would like to load the temp file to make changes or just be able to upload it somewhere, When I try to do so - It throws an error as shown below
I have set the permission to w+ - which should ideally allow me to read and write, Not sure what am I missing here - Any help would be appreciated - thanks
>>> from openpyxl import load_workbook
>>> from tempfile import NamedTemporaryFile
>>> import os
>>> with NamedTemporaryFile(suffix=".xlsx", mode='w+', delete=True) as tmp:
... temp_path = tmp.name
... os.path.exists(temp_path)
... wb = load_workbook(temp_path)
...
True
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "C:\Users\my_name\VS_PROJECTS\.venv\lib\site-packages\openpyxl\reader\excel.py", line 315, in load_workbook
reader = ExcelReader(filename, read_only, keep_vba,
File "C:\Users\my_name\VS_PROJECTS\.venv\lib\site-packages\openpyxl\reader\excel.py", line 124, in __init__
self.archive = _validate_archive(fn)
File "C:\Users\my_name\VS_PROJECTS\.venv\lib\site-packages\openpyxl\reader\excel.py", line 96, in _validate_archive
archive = ZipFile(filename, 'r')
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2288.0_x64__qbz5n2kfra8p0\lib\zipfile.py", line 1251, in __init__
self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\my_name\\AppData\\Local\\Temp\\tmp5dsrqegj.xlsx'