forked from rui2333/MadHacks-Judging-Tool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse.py
66 lines (54 loc) · 2.24 KB
/
parse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import csv
from sys import argv
script, JudgesNumber = argv
with open('submissions.csv', 'r', encoding="utf8") as f:
reader = csv.reader(f)
submissionsRowList = list(reader)
'''
Removes unneeded columns for the submissions.csv file. Keeps the following columns (in order):
Submission Title
Submission URL
Desired Prizes
'''
for row in submissionsRowList:
del row[2] # Delete Plain Description
del row[2] # Delete Video
del row[2] # Delete Website
del row[2] # Delete File Url
'''
Deletes the following columns:
Built With
Mlh points
Mlh Hardware Lab
Mlh Submitter Screen Name
College/Universities Of Team Members
Additional Team Member Count
Team Members (Deletes up to 3 Members. May need to change depending on max # of members per team)
'''
for x in range(1, 11):
del row[3]
with open('Parsed_File_For_Teams.csv', 'w', newline='') as team_file, \
open('Parsed_File_For_Judges.csv', 'w', newline='') as judges_file:
teamWriter = csv.writer(team_file, delimiter=',')
judgeWriter = csv.writer(judges_file, delimiter=',')
# Print First Row for 'Parsed_File_For_Judges.csv'
judgeList = []
for judgeNumber in range(0, int(JudgesNumber)):
judgeList.append('Judge ' + str(judgeNumber+1))
judgeWriter.writerow(['Submission'] + ['Table Number'] + judgeList)
# Print first row for 'Parsed_File_For_Teams.csv'
teamWriter.writerow(submissionsRowList[0] + ['Table Number'])
# Remove first row for parsing projects
submissionsRowList.remove(submissionsRowList[0])
# Print the rest of the rows for 'Parsed_File_For_Judges.csv' and 'Parsed_File_For_Teams.csv'
tableNumber = 1
for line in submissionsRowList:
# Used to split judges evenly among all projects
assignedJudgeNumber = int(((tableNumber-1)/int((len(submissionsRowList)/int(JudgesNumber)))+1))
# Writes Row for 'Parsed_File_For_Judges.csv'
markedJudges = [""] * int(JudgesNumber)
markedJudges[int(assignedJudgeNumber)-1] = 'x'
judgeWriter.writerow([str(line[0])] + [tableNumber] + markedJudges)
# Writes Row for 'Parsed_File_For_Teams.csv'
teamWriter.writerow(line + [tableNumber])
tableNumber += 1