You can convert this Excel XML file programmatically. Requirement: only python and pandas.

import pandas as pd
from xml.sax import ContentHandler, parse

# Reference https://www.oreilly.com/library/view/python-cookbook-2nd/0596007973/ch12s08.html
class ExcelHandler(ContentHandler):
    def __init__(self):
        self.chars = [  ]
        self.cells = [  ]
        self.rows = [  ]
        self.tables = [  ]
    def characters(self, content):
        self.chars.append(content)
    def startElement(self, name, atts):
        if name=="Cell":
            self.chars = [  ]
        elif name=="Row":
            self.cells=[  ]
        elif name=="Table":
            self.rows = [  ]
    def endElement(self, name):
        if name=="Cell":
            self.cells.append(''.join(self.chars))
        elif name=="Row":
            self.rows.append(self.cells)
        elif name=="Table":
            self.tables.append(self.rows)

excelHandler = ExcelHandler()
parse('coalpublic2012.xls', excelHandler)
df1 = pd.DataFrame(excelHandler.tables[0][4:], columns=excelHandler.tables[0][3])
Answer from jrovegno on Stack Overflow
🌐
Python.org
discuss.python.org › python help
Convert xml to excel/csv - Python Help - Discussions on Python.org
October 15, 2022 - Please help me in converting XML file into excel/csv. Thank you in advance.
🌐
Like Geeks
likegeeks.com › home › python › pandas › export xml to excel using python pandas
Export XML to Excel using Python Pandas
April 27, 2025 - You can export XML files to Excel by reading the XML using Pandas read_xml() and then exporting the result DataFrame to Excel using Pandas to_excel().
Discussions

python - How to convert an XML file to an Excel file? - Stack Overflow
I have a directory which contains multiple XML files, lets say it contains the following 2: Madird01 Madird More on stackoverflow.com
🌐 stackoverflow.com
excel - Converting .xml into .xlsx python pandas - Stack Overflow
If I open it manually with excel ... it with pandas too. I don't need it in excel format, but that was the only solution that worked for me to use it as dataframe. ... Your file corrupted for whatever reason probably. You could try a CSV instead of an Excel file if the actual type doesn't matter. ... I've tried it to convert it directly from xml to dataframe ... More on stackoverflow.com
🌐 stackoverflow.com
October 19, 2021
python - How to read XML file into Pandas Dataframe like Read XML Table in Excel - Stack Overflow
I have an xml file and I am trying to iterate through the tags to convert it to a pandas dataframe. My current process is to open the XML file with excel as an "XML table" but this takes forever. T... More on stackoverflow.com
🌐 stackoverflow.com
python - How to convert an XML file to nice pandas dataframe? - Stack Overflow
You can easily use xml (from the Python standard library) to convert to a pandas.DataFrame. More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 3
2

create a csv file which is Excel friendly format.

import xml.etree.ElementTree as ET
from os import listdir


xml_lst = [f for f in listdir() if f.startswith('xml')]
fields = ['RecordID','I_25Hz_1s','I_75Hz_2s'] # TODO - add rest of the fields
with open('out.csv','w') as f:
  f.write(','.join(fields) + '\n')
  for xml in xml_lst:
    root = ET.parse(xml)
    values = [root.find(f'.//{f}').text for f in fields]
    f.write(','.join(values) + '\n')

output

RecordID,I_25Hz_1s,I_75Hz_2s
Madird01,56.40,0.36
London01,56.40,0.36
2 of 3
1

When you need to iterate over files in folder with similar names one of the ways could be make a pattern and use glob. To make sure that returned path is file you can use isfile().

Regarding XML, I see that basically you need to write values of every terminal tag in column with name of this tag. As you have various files you can create tag-value dictionaries from each file and store them into ChainMap. After all files processed you can use DictWriter to write all data into final csv file.

This method is much more safe and flexible then use static column names. Firstly program will collect all possible tag(column) names from all files, so in case if XML doesn't have such a tag or have some extra tags it won't throw an exception and all data will be saved.

Code:

import xml.etree.ElementTree as ET
from glob import iglob
from os.path import isfile, join
from csv import DictWriter
from collections import ChainMap

xml_root = r"C:\data\Desktop\Blue\XML-files"
pattern = "xmlfile_*"
data = ChainMap()
for filename in iglob(join(xml_root, pattern)):
    if isfile(filename):
        tree = ET.parse(filename)
        root = tree.getroot()
        temp = {node.tag: node.text for node in root.iter() if not node}
        data = data.new_child(temp)

with open(join(xml_root, "data.csv"), "w", newline="") as f:
    writer = DictWriter(f, data)
    writer.writeheader()
    writer.writerows(data.maps[:-1])  # last is empty dict

Upd. If you want to use xlsx format instead of csv you have to use third-party library (e.g. openpyxl). Example of usage:

from openpyxl import Workbook

...

wb = Workbook(write_only=True)
ws = wb.create_sheet()
ws.append(list(data))  # write header
for row in data.maps[:-1]:
    ws.append([row.get(key, "") for key in data])
wb.save(join(xml_root, "data.xlsx"))
🌐
Oracle
blog.toadworld.com › home › python for data science – importing xml to pandas dataframe
Python for Data Science – Importing XML to Pandas DataFrame - The Quest Blog
September 7, 2025 - In my previous post, I showed how easy to import data from CSV, JSON, Excel files using Pandas package. Another popular format to exchange data is XML. Unfortunately Pandas package does not have a fun...
🌐
Stack Overflow
stackoverflow.com › questions › 69636125 › converting-xml-into-xlsx-python-pandas
excel - Converting .xml into .xlsx python pandas - Stack Overflow
October 19, 2021 - If I open it manually with excel ... it with pandas too. I don't need it in excel format, but that was the only solution that worked for me to use it as dataframe. ... Your file corrupted for whatever reason probably. You could try a CSV instead of an Excel file if the actual type doesn't matter. ... I've tried it to convert it directly from xml to dataframe ...
🌐
Quora
quora.com › How-can-you-convert-an-Excel-table-into-an-XML-file-without-external-software-Alternatively-from-Python-Pandas-to-XML
How to convert an Excel table into an XML file without external software? (Alternatively from Python Pandas to XML - Quora
Answer (1 of 5): * How can you convert an Excel table into an XML file without external software? (Alternatively from Python Pandas to XML?) That answers that suggest you simple save the file as XML are correct. Several answers include mention that Excel (and Word etc) files are no technically ...
Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_xml.html
pandas.read_xml — pandas documentation - PyData |
Read XML document into a DataFrame object. ... String path, path object (implementing os.PathLike[str]), or file-like object implementing a read() function. The string can be a path. The string can further be a URL. Valid URL schemes include http, ftp, s3, and file.
🌐
GitHub
github.com › vrushabhkaushik › XML-to-Excel-Conversion
GitHub - vrushabhkaushik/XML-to-Excel-Conversion: The python script reads the XML file name from user's input, and then using data frame, it writes the data to an Excel sheet
The python script reads the XML file name from user's input, and then using data frame, it writes the data to an Excel sheet - vrushabhkaushik/XML-to-Excel-Conversion
Starred by 5 users
Forked by 2 users
Languages   Python 100.0% | Python 100.0%
🌐
Like Geeks
likegeeks.com › home › python › pandas › parsing xml files into dataframes using pandas read_xml
Parsing XML Files into DataFrames using Pandas read_xml
October 16, 2023 - Export XML to CSV using Python Pandas · Export XML to Excel using Python Pandas · Read Excel files using Pandas read_excel · Read JSON files using Python Pandas read_json · Read SQL Query/Table into DataFrame using Pandas read_sql · Read HTML tables using Pandas read_html function ·
🌐
PyPI
pypi.org › project › xml2xlsx
xml2xlsx · PyPI
This is a merely an xml parser translating mostly linearly to worksheet, rows and finally cells of the Excel workbook.
      » pip install xml2xlsx
    
Published   Sep 16, 2024
Version   1.0.2
🌐
Stack Abuse
stackabuse.com › reading-and-writing-xml-files-in-python-with-pandas
Reading and Writing XML Files in Python with Pandas
August 21, 2024 - In this article, you will learn how to read data from an XML file and load it into a Pandas DataFrame. You'll also export data from a Pandas DataFrame to an XML file.
🌐
Table Convert
tableconvert.com › home › convert xml to pandas dataframe online
Convert XML to Pandas DataFrame Online - Table Convert
January 11, 2019 - Use the extension to detect and extract tables from any page, then paste the data here to convert XML to PandasDataFrame. Instantly extract tables from any webpage without copy-pasting - professional data extraction made simple · Convert extracted tables to Excel, CSV, JSON, Markdown, SQL, and more with our advanced table converter
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.read_xml.html
pandas.read_xml — pandas 2.2.2 documentation - PyData |
Only ‘lxml’ and ‘etree’ are supported. With ‘lxml’ more complex XPath searches and ability to use XSLT stylesheet are supported. ... A URL, file-like object, or a raw string containing an XSLT script. This stylesheet should flatten complex, deeply nested XML documents for easier parsing.
🌐
Like Geeks
likegeeks.com › home › python › pandas › convert pandas dataframe to xml file using to_xml
Convert Pandas DataFrame to XML File Using to_xml
April 21, 2024 - Export XML to CSV using Python Pandas · Export XML to Excel using Python Pandas · Convert Python Pandas DataFrame to JSON using to_json · Export Python Pandas DataFrame to SQL using to_sql · Convert Python Pandas DataFrame to HTML table using to_html · Parsing XML Files into DataFrames using Pandas read_xml ·