Last active
December 6, 2018 03:39
-
-
Save SamyBencherif/fde7c3bca702545dd22739dd8caf796a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import csv | |
with open('C:/Users/rohan/Desktop/Google Drive/honourCSVreader/honour.csv') as csv_file: | |
csv_reader = csv.reader(csv_file, delimiter=",") | |
subjects = ['English', 'Math', 'Geography', 'Science', 'Gym', 'History', 'Art', 'Music'] | |
award_winners = [[set(), 0], [set(), 0], [set(), 0], [set(), 0], [set(), 0], [set(), 0], [set(), 0], [set(), 0]] | |
# Honour Roll | |
print('The honour roll students are:') | |
print("-" * 40) | |
csv_file.readline() | |
for row in csv_reader: | |
subtotal = 0 | |
for i in range(2, 8 + 2): | |
subtotal += int(row[i]) | |
if int(row[i]) > award_winners[i-2][1]: | |
award_winners[i - 2][0] = set() | |
if int(row[i]) >= award_winners[i-2][1]: | |
award_winners[i - 2][0].add(row[1] + " " + row[0]) | |
award_winners[i - 2][1] = int(row[i]) | |
avg = subtotal / 8. | |
if avg > 80: | |
print(row[1] + " " + row[0], avg) | |
# Subject Awards | |
print("-" * 40) | |
print('The subject award winners are:') | |
print("-" * 40) | |
for ix, student_grade in enumerate(award_winners): | |
print('\n{subject} ({score}): \n{names}'.format(subject=subjects[ix], names='\n'.join(list(student_grade[0])), score=student_grade[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment