forked from karpathy/jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_site_data.py
More file actions
56 lines (45 loc) · 1.58 KB
/
Copy pathbuild_site_data.py
File metadata and controls
56 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Build a compact JSON for the website by merging CSV stats with AI exposure scores.
Reads occupations.csv (for stats) and scores.json (for AI exposure).
Writes site/data.json.
Usage:
uv run python build_site_data.py
"""
import csv
import json
def main():
# Load AI exposure scores
with open("scores.json") as f:
scores_list = json.load(f)
scores = {s["slug"]: s for s in scores_list}
# Load CSV stats
with open("occupations.csv") as f:
reader = csv.DictReader(f)
rows = list(reader)
# Merge
data = []
for row in rows:
slug = row["slug"]
score = scores.get(slug, {})
data.append({
"title": row["title"],
"slug": slug,
"category": row["category"],
"pay": int(row["median_pay_annual"]) if row["median_pay_annual"] else None,
"jobs": int(row["num_jobs_2024"]) if row["num_jobs_2024"] else None,
"outlook": int(row["outlook_pct"]) if row["outlook_pct"] else None,
"outlook_desc": row["outlook_desc"],
"education": row["entry_education"],
"exposure": score.get("exposure"),
"exposure_rationale": score.get("rationale"),
"url": row.get("url", ""),
})
import os
os.makedirs("site", exist_ok=True)
with open("site/data.json", "w") as f:
json.dump(data, f)
print(f"Wrote {len(data)} occupations to site/data.json")
total_jobs = sum(d["jobs"] for d in data if d["jobs"])
print(f"Total jobs represented: {total_jobs:,}")
if __name__ == "__main__":
main()