Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (60 sloc) 2.03 KB
# this whole file is horrendous
import csv
users = {}
template = open("divtemplate").read()
with open("flights.csv") as cf:
r = csv.reader(cf)
for line in r:
if line[0] not in users:
users[line[0]] = {"flights": 0, "sample": 0, "degrade": 0, "deliveries": 0, "cures": 0, "hadCure": False}
users[line[0]]["flights"] += 1
if line[4] == "sd": # sample and degrade
users[line[0]]["sample"] += 1
users[line[0]]["degrade"] += 1
elif line[4] == "de": # sample deliveries
users[line[0]]["deliveries"] += 1
elif line[4] == "dg": # degrades
users[line[0]]["degrade"] += 1
elif line[4] == "cu": # cures
users[line[0]]["cures"] += 1
elif line[4] == "gc": # cure obtains
users[line[0]]["hadCure"] = True
elif line[4] == "na": # nothing special
pass
else:
print(f"WHATZEFUK {line[4]}")
outputs = []
sorted_users = []
for key in sorted(users.keys()):
temp_val = users[key]
temp_val["name"] = key
sorted_users.append(temp_val)
for user in sorted_users:
cut = user["name"].split("[")
username = cut[0].strip()
callsign = cut[1].split("]")[0].strip()
outputs.append(template.format(username, callsign, username, str(user["flights"]), str(user["sample"]), str(user["degrade"]), str(user["deliveries"]), ("Yes" if user["hadCure"] is True else "No"), str(user["cures"]))
)
rows = []
switch = True
counter = 0
while switch:
temp = []
for i in range(2):
try:
temp.append(outputs[counter + i] + "\n")
except IndexError:
pass
try:
rows.append(temp[0] + temp[1])
except IndexError:
rows.append(temp[0])
counter += 2
if counter >= len(outputs):
switch = False
finout = ""
for i in range(len(rows)):
finout += '<div class="row">\n'
finout += rows[i]
finout += '</div>\n'
print(finout)
You can’t perform that action at this time.