import csv import json from pathlib import Path import awork_tasks with Path(__file__).parent.joinpath("projects.json").open("r") as frh: projects = json.load(frh) project_types = [(p["id"], p["name"], p["projectType"]["name"], p["isBillableByDefault"]) for p in projects] header = ["id", "name", "type", "is_billable_by_default"] with Path(__file__).parent.joinpath("project_types.csv").open("w", newline="", encoding="latin-1") as frh: csv_writer = csv.writer(frh, delimiter=";") csv_writer.writerow(header) csv_writer.writerows(project_types)