We discovered that the student information system generates multiple records for a given student_id under certain circumastances. if student is, for example, registered in both Grad studies and an undergraduate course, their records would appear in both the grad.xls and the uow.xls file respectively. In the current code, the input files are processed in whatever order
glob('*.xls')
returns them. This means that the value of PatronType is determined by whichever file runs last. Rather than following that rule, the code should behave in accordance with the library's patron privileges policy.
The library's policy is to grant access based on the most advanced level in which a student is registered. So the hierarchy from least to most advanced is (with PatronType.pcode in parens):