Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup authority fields automatically #83

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
Manually copying dozens of scorecard questions from Excel isn't feasible, so these scripts automate that process. The CSV files are **not** intended to be edited later and the scripts re-run; the source of truth becomes the generated Svelte files. Those files are **manually edited** to adjust wording, add links, introduce formatting, etc. Everything is checked in here just for reference.

The CSV input files were made with LibreOffice, saving each sheet as a CSV with default options. Leading and trailing lines were manually deleted.

`authorities.csv` comes from PowerBI, not the original tools.
32 changes: 32 additions & 0 deletions codegen/authorities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import csv

authorities = []
combinedAuthorities = set()
regions = set()
with open("inputs/authority-relations.csv") as inputFile:
for row in csv.DictReader(inputFile):
if row["Authority Type"] != "National Park":
ca = row["Combined Authority"]
region = row["ATE Region"]
authorities.append((row["Authority Name"], ca, region))
if ca:
combinedAuthorities.add(ca)
if region:
regions.add(region)

print("export let authorities = [")
print(""" ["N/A", "", ""],""")
for row in sorted(list(set(authorities))):
print(""" ["{}", "{}", "{}"],""".format(*row))
print("];\n")

print("export let transportOrCombinedAuthorities = [")
print(""" "Not applicable",""")
for x in sorted(list(combinedAuthorities)):
print(""" "{}",""".format(x))
print("];\n")

print("export let regions = [")
for x in sorted(list(regions)):
print(""" "{}",""".format(x))
print("];\n")
636 changes: 636 additions & 0 deletions codegen/inputs/authority-relations.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading