Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read MS Excel XML file to pandas dataframe?

I have an MS Excel XML (2003) file with the following metadata:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" 
xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" 
xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" 
xmlns:x="urn:schemas-microsoft-com:office:excel" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">

I'd like to read it into a pandas dataframe. What's a good way to go about doing this? Thanks.

like image 824
Lamps1829 Avatar asked Jul 24 '13 11:07

Lamps1829


People also ask

How do you read data from Excel file in Python using pandas?

We can use the pandas module read_excel() function to read the excel file data into a DataFrame object. If you look at an excel sheet, it's a two-dimensional table. The DataFrame object also represents a two-dimensional tabular data structure.

Can we convert XML to DataFrame in Python?

xml” file starts at the root of the tree, namely the <data> element, which contains the entire data structure. Now we can iterate through each node of the tree, which means we will get each student element and grab its name attribute and all of its sub-elements to build our dataframe.


1 Answers

Did you try Canopy python's pyxll, it is advertised as "Python for Excel Solution"

Check it out please and see if it solves your problem.

like image 181
dgg32 Avatar answered Oct 26 '22 14:10

dgg32