Syndicate604's picture
Skills Desk v1: 40 training tasks, 20 reserved evaluation tasks (frozen)
a785ccd verified
Raw History Blame Contribute Delete
425 Bytes
import csv
import xml.etree.ElementTree as ET
w = csv.writer(open("catalog.csv", "w", newline="", encoding="utf-8")); w.writerow(["sku", "title", "price", "stock", "tags"])
for p in ET.parse("catalog.xml").getroot().findall("product"):
st = p.find("stock")
w.writerow([p.get("sku"), p.findtext("title"), p.findtext("price"), "" if st is None else st.text,
";".join(t.text for t in p.findall("tag"))])