Files
xml-pandas/main.py
2024-02-14 18:21:33 +01:00

21 lines
437 B
Python

import xmltodict
import pprint
import pandas as pd
# Open the file and read the contents
with open('test_data.tcx', 'r', encoding='utf-8') as file:
my_xml = file.read()
# Use xmltodict to parse and convert the
# XML document
my_dict = xmltodict.parse(my_xml)
df = pd.DataFrame.from_dict(my_dict)
df.name = "test"
# Print the dictionary
#pprint.pprint(my_dict, indent=2)
print("DataFrame name: ", df.name)
print(df)