import csv from opyml import OPML, Outline def main() -> None: document = OPML() with open("examples/csv-to-opml.csv", "r") as example_csv: csv_reader = csv.DictReader(example_csv) for row in csv_reader: document.body.outlines.append( Outline( # Convert to str because text is a required OPML attribute # and row.get() can return None. text=str(row.get("Text")), xml_url=row.get("Url"), ) ) print(document.to_xml()) if __name__ == "__main__": main()