I have to get the content from a page that is in XML format into a data frame.
My code to read the file is:
from urllib.request import urlopen
import re
import pandas as pd
import xmltodict
from collections import OrderedDict
x= urlopen('https://mpr.datamart.ams.usda.gov/ws/report/v1/cattle/LM_CT138?filter=%7B%22filters%22:%5B%7B%22fieldName%22:%22Report%20date%22,%22operatorType%22:%22EQUAL%22,%22values%22:%5B%224/1/2022%22%5D%7D%5D%7D').read().decode('utf-8')
data = xmltodict.parse(x)
print(data)
The output is in ordered Dictionary and I tried number of ways to convert it to the required data frame.
Example
keys = data.keys()
values = data.values()
print ("keys : ", str(keys))
print ("values : ", str(values))
pd.DataFrame.from_dict(values)
I am getting the entire dictionary in one column. I want them split with according to the key values in different coulms.
