Created
October 16, 2019 09:54
-
-
Save wolframalpha/c952e46daa27f3ba22aa80f645cd906d to your computer and use it in GitHub Desktop.
Read Label.me xml file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import pandas as pd | |
soup = BeautifulSoup(open('00001.xml'), 'xml') | |
objs = soup.find_all('object') | |
data = [] | |
for obj in objs: | |
x = [x.get_text() for x in obj.find_all('x')] | |
y = [y.get_text() for y in obj.find_all('y')] | |
name = obj.find('name').get_text() | |
data.append([name, x, y]) | |
df = pd.DataFrame(data, columns=['name', 'x', 'y']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment