Last active
January 14, 2018 20:05
-
-
Save noahbass/26884f6c1f5b95bbee9b71514b17978e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# First, run: | |
# virtualenv venv | |
# . venv/bin/activate | |
# pip install beautifultable | |
import csv | |
from beautifultable import BeautifulTable | |
# import numpy as np | |
# map: 6+2 -> graduation_date | |
input_data = {} | |
with open('2017-fall-attendance.csv', newline='') as csvfile: | |
reader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
index = 0 | |
for row in reader: | |
index += 1 | |
if index == 1: | |
continue | |
full_name = row[1] | |
six_plus_two = row[3].lower() | |
graduation_date = row[4] | |
num_attended = 0 | |
# if graduation_date != 'Graduate Student': | |
# graduation_date = int(graduation_date) | |
# if graduation_date == 2021 or graduation_date == 2022: | |
if six_plus_two in input_data.keys(): | |
input_data[six_plus_two]['num_attended'] += 1 | |
else: | |
input_data[six_plus_two] = {} | |
input_data[six_plus_two]['num_attended'] = 1 | |
input_data[six_plus_two]['full_name'] = full_name | |
input_data[six_plus_two]['6+2'] = six_plus_two | |
input_data[six_plus_two]['graduation_date'] = graduation_date | |
# matrix = [['Name', '6+2', 'Num Attended', 'Grad Date']] | |
table = BeautifulTable() | |
table.column_headers = ['Name', '6+2', 'Num Attended', 'Grad Date'] | |
for key, value in input_data.items(): | |
if value['num_attended'] >= 1: | |
# matrix.append([value['full_name'], value['6+2'], value['num_attended'], value['graduation_date']]) | |
table.append_row([value['full_name'], value['6+2'], value['num_attended'], value['graduation_date']]) | |
print(table) | |
print(len(table)) | |
# print(matrix) | |
# print(np.matrix(matrix)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment