XML file reading error "Error reading file 'xmlfile.xml': failed to load external entity "xmlfile.xml""

When i am trying to delete some sheet from excel file i am getting “XML file reading error” i am using below python code to delete sheet with the name of “Evaluation”.

import openpyxl as xl

wb1 = xl.load_workbook(“file location with path”)

for i in wb1.sheetnames:
if(i.find(“Evaluation”) == 0 or i.find(“Evaluation”.lower()) == 0):
del wb1[i]

wb1.save(“file saving location”)

I am writing this code python script node and when i am executing this code in the node i am getting below error.

, in
File “src/lxml/etree.pyx”, line 3521, in lxml.etree.parse
File “src/lxml/parser.pxi”, line 1859, in lxml.etree._parseDocument
File “src/lxml/parser.pxi”, line 1885, in lxml.etree._parseDocumentFromURL
File “src/lxml/parser.pxi”, line 1789, in lxml.etree._parseDocFromFile
File “src/lxml/parser.pxi”, line 1177, in lxml.etree._BaseParser._parseDocFromFile
File “src/lxml/parser.pxi”, line 615, in lxml.etree._ParserContext._handleParseResultDoc
File “src/lxml/parser.pxi”, line 725, in lxml.etree._handleParseResult
File “src/lxml/parser.pxi”, line 652, in lxml.etree._raiseParseError
OSError: Error reading file ‘xmlfile.xml’: failed to load external entity “xmlfile.xml”

This error so if you guys have any idea or guidance to solve this error please guide. for your better understanding i have attached image of an error.

Thank you guys in advance

Hi @shubham_knime -

Can you upload an example workflow and Excel file that reproduces the problem? It seems like this mystery file “xmlfile.xml” is missing, but you don’t show the exact path that you’re trying to read.

Maybe @mlauber71 will have some insight, he is quite familiar with openpxyl. But having an actual workflow for us to debug is crucial :slight_smile:

1 Like

@shubham_knime you could take a look at this example removing a specific sheet from an excel file:

1 Like

I think the “del” command would remove an entire object in Python in this case a definition of the workbook you just set. I fear this might cause problems. This command might be better:



1 Like