def intr_docs(xml_doc):
attr = xml_doc.attrib
for chld in root:
for value in chld:
for xml in xml_doc.iter('timestep'):
doc_dict = attr.copy()
doc_dict.update(xml.attrib)
doc_dict['time'] = chld.attrib['time']
doc_dict['id'] = value.attrib['id']
doc_dict['speed'] = value.attrib['speed']
doc_dict['lane'] = value.attrib['lane']
yield doc_dict
doc_df = pd.DataFrame(list(intr_docs(root)))
<timestep time="28800.00"/>
<timestep time="28890.00">
<vehicle id="800002" x="5534.41" y="3530.10" angle="243.59" type="HV" speed="14.58" pos="5.10" lane="-gneE13_2" slope="0.00"/>
<vehicle id="800003" x="4190.43" y="3359.53" angle="88.95" type="HV" speed="12.64" pos="5.10" lane="-5088609#2_0" slope="0.00"/>
<vehicle id="800017" x="1972.35" y="437.35" angle="306.80" type="HV" speed="15.17" pos="5.10" lane="-gneE5_2" slope="0.00"/>
<vehicle id="800021" x="9.34" y="-1.68" angle="42.62" type="HV" speed="13.32" pos="5.10" lane="-gneE6_1" slope="0.00"/>
<vehicle id="800034" x="2616.22" y="1599.61" angle="318.00" type="HV" speed="14.54" pos="5.10" lane="-gneE2_0" slope="0.00"/>
<vehicle id="800053" x="2915.19" y="2618.33" angle="290.01" type="HV" speed="16.52" pos="5.10" lane="-6200994#2_0" slope="0.00"/>
</timestep>
I am new to python. I have XML file (attached image)1 and want to convert it into the dataframe (attached image)2. I got the code and converted the file (13 MB) as I wanted but in the case of a large file (more than 500 MB) it is taking a lot of time. I am wondering it is due to code or my PC capacity. So how can I do it.