The immediate cause of the error is trying to open a table file that was not previously closed. This error could be caused by:
In the process before
- the workbook that was opened did not have a normal close, resulting in additional temporary files, and errors occurred when trying to open these temporary files; The workbook before
- did not overwrite the existing files when saving.
can also be other errors, but it doesn’t matter, look at the solution, you can from the root to avoid this kind of error about load/save .
open and exit excel files in a safe way, you can avoid the above type of load/save error. When opening a file, open excel in the following ways: if the original file already exists, just load it directly; If it doesn’t exist, create a new workbook and prepare the last save.
import os from openpyxl import Workbook from openpyxl import load_workbook if os.path.exists(new_filename): new_wb = load_workbook(new_filename) else: new_wb = Workbook()
is safely saved as excel
- first, remember to exit as soon as you run out of files. Second, when exiting a file, for all workbooks, if you need to save, if you don’t need to save (read-only), be sure to close
wb.save(filename) # For workbooks that need to save written content wb.close() # Read-only workbook for the program
- python2.7 ExcelWriter error Exception caught in workbook destructor. Explicit close() may be require
- Python writes DICOM file (attributeerror: ‘filemetadataset’ object has no attribute ‘transfersyntax uid’ solution)
- How to Fix pandas.errors.ParserError Error tokenizing data C error Buffer overflow caught
- Python: How to get the size of the picture (byte/kb/mb)
- python: File Processing and Input and Output
- Python FileNotFoundError: [Errno 2] No such file or directory: ‘objects/epsilon.pkl
- The automatic token of Python interface is passed into the header
- A summary of a demo development process for Python using the QT5 development interface
- Python: How to Encode the File (including HTML, TXT, Doc, etc.)
- How to Fix Python reading large local file memory error
- Pyyaml tutorial introduction to pyyaml library and YML writing and reading
- Python 3.X error: valueerror: data type must provide an itemsize
- Python IndexError: too many indices for array: array is 1-dimensional, but 2 were i..
- How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)
- [How to Fix]pandas.errors.ParserError: Error tokenizing data
- Python: How to parses HTML, extracts data, and generates word documents
- Command “/usr/bin/python -u -c “import setuptools, tokenize；__file__=‘/tmp/pip-cus9V0-build/setup.py
- Python TypeError: coercing to Unicode: need string or buffer, NoneType found
- [zipfile] Python packages files as zip packages & decompresses them
- Python: How to Delete Empty Files or Folders in the Directory