Last active
April 29, 2020 20:33
-
-
Save nicholsonjf/14deeaf7b81d879fddc7b91597a1a4f7 to your computer and use it in GitHub Desktop.
Mailman Faculty Parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, csv | |
reg = re.compile('(?<=Name: )(?P<faculty_name>.+)(?= HUID).+(?<=NETID: )(?P<faculty_3x3>.+)(?= EPPN)') | |
with open('grouper-export/groupExportAll_SPHFaculty.csv') as fdata: | |
freader = csv.reader(fdata) | |
with open('faculty-filenames.csv', 'w') as ffile: | |
fieldnames = ['faculty_name', 'faculty_3x3', 'filename'] | |
writer = csv.DictWriter(ffile, fieldnames=fieldnames) | |
writer.writeheader() | |
for row in freader: | |
result = reg.finditer(row[1]) | |
for obj in result: | |
rowDict = obj.groupdict() | |
rowDict['filename'] = rowDict['faculty_3x3'] + '.jpg' | |
writer.writerow(rowDict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment