import json, re
with open('index_main.html', encoding='utf-8') as f: html = f.read()
m = re.search(r'const PROGRAMS\s*=\s*\[([\s\S]*?)\n\];', html)
body = m.group(1)
entries = re.findall(r'\{id:"([^"]+)"[^}]*?s:"([^"]+)"[^}]*?en:"([^"]+)"[^}]*?deg:"([^"]+)"', body)
have_en = {en.lower().strip() for (i,s,en,deg) in entries}
have_ids = {i for (i,s,en,deg) in entries}
with open('todo_upgrade.json', encoding='utf-8') as f: todo = json.load(f)
remaining = [t for t in todo if t.get('en','').lower().strip() not in have_en]
print('Remaining by en-not-match:', len(remaining))
# Group by school
from collections import Counter
c = Counter(t.get('s','') for t in remaining)
print('By school:')
for k,v in c.most_common(): print(f'  {k}: {v}')
# Show first 30 by school
print('\nFirst 40 candidates:')
for r in remaining[:40]:
    print(' ', r.get('s'), '|', r.get('en'), '|', r.get('deg'), '|', r.get('disc'))
