I am fairly new to python and am looking for some guidance on my python code. I have multiple XML files that I would like to put into ONE data frame. Each XML file is one record. My code below puts the data into multiple data frames but am trying to find a solution to append the rows to one data frame. Any help is greatly appreciated!
Here is my existing code
from bs4 import BeautifulSoup
import lxml
import pandas as pd
import os
import xml.etree.ElementTree as et
path = '/app/notebooks'
for filename in os.listdir(path):
if filename.endswith('.xml'):
fullname = os.path.join(path, filename)
soup = BeautifulSoup(open(fullname, "r"), "xml")
d = {}
for tag in soup.RECORDING.find_all(recursive=False):
d[tag.name] = tag.get_text(strip=True)
df = pd.DataFrame([d])
pd.set_option('display.max_columns', None)
display (pd.DataFrame(df))
Current output: 2 data frames but I'm trying to output 1 data frame with 2 records