Because of course the system that UNB paid literal millions of dollars for cannot actually tell me if students in my course have passed (with C or above) the single prerequisite course. I could handle either a small number of false positives, but apparently it also has an unknown number of false negatives (missed students) and no way to detect those without checking every student. Which makes this very expensive report useless.
In the unlikely event someone else finds this useful. Or just wants to make fun of my Python.
import csv
import sys
enrolled=set()
passed=set()
record={}
with open (sys.argv[1], 'r') as rosterfile:
rosterreader=csv.DictReader(rosterfile)
for row in rosterreader:
id=row['Student ID']
enrolled.add(id)
record[id]=row
with open ('report.csv', 'w') as outfile:
with open (sys.argv[2], 'r') as historyfile:
historyreader=csv.DictReader(historyfile)
writer = None
for row in historyreader:
if not writer:
fields=row.keys()
writer = csv.DictWriter(outfile,fieldnames=fields)
writer.writeheader()
id=row['StudentID']
grade=row['Final Grade']
if not grade in ['F', 'D', 'C-']:
passed.add(id)
if id in enrolled:
writer.writerow(row)
print("Students missing prerequisite:\n")
for id in enrolled.difference(passed):
row=record[id]
print(f"{row['Student ID']}\t{row['Student Name']}\t{row['Preferred Email']}")