简体   繁体   中英

How to Parse XML saved in Excel cell

I have excel file which contains XML data in each cell of column, I want to parse those XML data in each cell and save each to new file. Here is my code:

import pandas as pd
import numpy as np
import xml.etree.cElementTree as et
file_path = r'C:\Users\user\Documents\datasets\sample.xlsx'
df = pd.read_excel(file_path)
for i in count_row:
    pd.read_xml(df['XML'].iloc[i])

Here's sample file and Here's desired output

Instead of pandas, you could also look at openpyxl. This might make it easier for you to carve out the data that you need. You are mentioning that you want to parse the XML, but not specifying what you want to do with it... but, I would suggest xmltodict library for parsing XML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM