XML to pandas dataframe

I have a XML file with thousands of lines like:\[code\]<Word x1="206" y1="120" x2="214" y2="144" font="Times-Roman" style="font-size:22pt">WORD</Word>\[/code\]I want to convert it (all it's attributes) to pandas dataframe. To do that i could loop through the file using beautiful soup and insert the values row by row or create lists to be inserted as columns. However I would like to know if there's a more pythonic way of accomplishing what I described. Thank you in advance.Code example:\[code\]x1list=[]x2list=[]for word in soup.page.findAll('word'): x1list.append(int(word['x1'])) x2list.append(int(word['x2']))df=DataFrame({'x1':x1list,'x2':x2list})\[/code\]
 
Back
Top