Commit c7fd0d8
authored
Upload CT scorecard data (#316)
We're still missing the parking lot and boundaries, but this gets the
city stats uploaded at least.
This demonstrates that some entries are too long:
<img width="280" alt="Screenshot 2025-01-26 at 6 49 17 PM"
src="https://github.com/user-attachments/assets/0646b02b-3b15-42f6-b89e-a5f319e43cbd"
/>
JSON was generated with this script:
```python
import csv
import json
from pathlib import Path
def read_data() -> list[dict[str, str]]:
with Path("ct-scripts/ct-scorecards.csv").open(newline="") as csvfile:
reader = csv.DictReader(csvfile)
return sorted(reader, key=lambda row: row["Name"])
def name_to_id(v: str) -> str:
return v.lower().replace(" - ", "-").replace(" ", "-")
def fix_percentage(v: str) -> str:
num = float(v.replace("%", ""))
return f"{round(num)}%"
def transform_data(csv_data: list[dict[str, str]]) -> dict[str, dict[str, str | None]]:
return {
name_to_id(row["Name"]): {
"name": row["Name"],
"percentage": fix_percentage(row["Parking %"]),
"population": "121,054",
"transitStation": row["Transit Station"] or None,
"county": row["County"],
}
for row in csv_data
}
def main() -> None:
csv_data = read_data()
transformed_data = transform_data(csv_data)
Path("packages/ct/data/city-stats.json").write_text(json.dumps(transformed_data))
if __name__ == "__main__":
main()
```1 parent 2e1318e commit c7fd0d8
File tree
10 files changed
+1442
-60
lines changed- packages/ct
- data
- parking-lots
- src/js
- tests
10 files changed
+1442
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
0 commit comments