project_types.py 566 B

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