As the error message clearly states, your dictionary contains keys that don’t have a corresponding entry in your fieldnames
parameter. Assuming that these are just extra fields, you can ignore them by using the extrasaction
parameter during construction of your DictWriter
object:
writer = csv.DictWriter(csvfile, fieldnames=["Bio_Id","Last_Name","First_Name","late","undertime","total_minutes", "total_ot", "total_nsd", "total_absences"],
extrasaction='ignore', delimiter=";")