I am trying to create a xml from a dataframe . Issue that I am facing i want pass column into paramter and its not working.
ORDER_NO 1175 1304 1421
7283630 2019-12-04 2019-12-10 2019-12-12
7283650 2019-12-25 NaN 2019-12-20
My code
header = """<ORD>{}</ORD>"""
body ="""
<osi:ORDSTSINF types:STSCDE="{}">
<DTM>{}</DTM>
</osi:ORDSTSINF>
<osi:ORDSTSINF types:STSCDE="{}">
<DTM>{}</DTM>
</osi:ORDSTSINF>
<osi:ORDSTSINF types:STSCDE="{}">
<DTM>{}</DTM>
</osi:ORDSTSINF>"""
for row in df.itertuples():
with open(f'{row[1]}.xml', 'w') as f:
f.write(header.format(row[1]))
f.write(body.format(col[2], row[2], col[3],row[3],col[4],row[4]))
I want to pass then columnname wherever STS={} is coming.
Expected output
<ORD> 7283630</ORD>
<osi:ORDSTSINF types:STSCDE="1175">
<DTM>2019-12-04</DTM>
<osi:ORDSTSINF types:STSCDE="1304">
<DTM>2019-12-10</DTM>
<osi:ORDSTSINF types:STSCDE="1421">
<DTM>22019-12-12</DTM>
How can this be done in python?