Skip to content

Instantly share code, notes, and snippets.

@wolframalpha
Created October 16, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolframalpha/c952e46daa27f3ba22aa80f645cd906d to your computer and use it in GitHub Desktop.
Save wolframalpha/c952e46daa27f3ba22aa80f645cd906d to your computer and use it in GitHub Desktop.
Read Label.me xml file
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