Last active
January 3, 2016 04:59
-
-
Save niroyb/8412302 to your computer and use it in GitHub Desktop.
Analyse du fichier des résultats d'un cours à l'École Polytechnique de Montréal pour déterminer les seuils de chaque note.
Idée de EtiDuc : https://github.com/EtiDuc/poly-seuils-notes
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
'''Groupe les notes et permet de trouver les seuils''' | |
import re | |
from collections import defaultdict | |
with open('Resultat.txt') as f: | |
text = f.read() | |
matches = re.findall('((?:[A-F])(?:\*|\+|\s))\s*\|\s*([0-9.]+)', text) | |
print len(matches), 'notes :' | |
lettre_notes = defaultdict(list) | |
for lettre, note in matches: | |
lettre_notes[lettre].append(float(note)) | |
for lettre, notes in sorted(lettre_notes.items(), key=lambda x:max(x[1]), reverse=True): | |
print '{:<2} ({:>2}) [ {:>5.2f} - {:>5.2f} ]'.format(\ | |
lettre, len(notes), min(notes), max(notes)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output :