import json, re
data = json.load(open('todo_upgrade.json', encoding='utf-8'))
print('total:', len(data))
html = open('index_main.html', encoding='utf-8').read()
done = set(re.findall(r'\{id:"([^"]+)"', html))
print('done unique:', len(done))
remaining = []
for d in data:
    id_guess = d.get('id', '')
    if id_guess and id_guess in done:
        continue
    remaining.append(d)
print('remaining approx:', len(remaining))
priority = ['CS', 'Computer', 'Electrical', 'Finance', 'Financial', 'Econom', 'Business', 'Analytics', 'Data Science', 'Statistic', 'Mechanical', 'Biology', 'Biomed', 'Biostat', 'Management', 'Information', 'Math', 'Applied Math', 'Engineering', 'Physics', 'Chemistry']
seen = set()
picks = []
for d in remaining:
    en = d.get('en', '')
    if any(p.lower() in en.lower() for p in priority):
        key = (d.get('s', ''), en.lower())
        if key in seen:
            continue
        seen.add(key)
        picks.append(d)
        if len(picks) >= 25:
            break
for p in picks:
    print(p.get('s', ''), '|', p.get('en', ''), '|', p.get('deg', ''), '|', p.get('col', ''), '|', p.get('id', ''))
