-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgirth.py
More file actions
162 lines (114 loc) · 3.82 KB
/
Copy pathgirth.py
File metadata and controls
162 lines (114 loc) · 3.82 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import openpyxl,sys
from openpyxl import *
def stringMSJ( input ) :
"This will parse the input string"
parsedString = input.split(",")
return parsedString
def highestRow( ws ) :
cellChecker = False
rowNum = 1
startCol = 'A'
while(cellChecker == False) :
if(ws[startCol + str(rowNum)].value == None) :
cellChecker = True
print("Row " + str(rowNum) + " is empty")
else :
print("Row " + str(rowNum) + " is not empty")
rowNum += 1
return rowNum
def excellInputer( parsedString ) :
teamNum = None
matchNum = None
alliance = None
startPosition = None
placedGear = None
scoredHG = None
scoredLG = None
numGear = None
numLG = None
numHG = None
climbed = None
matchNotes = None
startRow = 2
startCol = 'A'
tableX = 12
tableY = 6
countTeam = False
countMatch = False
teamList = 'WPITeamList.xlsx'
matchList = 'WPIMatchList.xlsx'
try:
output = stringMSJ(parsedString)
length = len(output)
if(length >= 1) : teamNum = output[0]
if(length >= 2) : matchNum = output[1]
if(length >= 3) : alliance = output[2]
if(length >= 4) : startPosition = output[3]
if(length >= 5) : placedGear = output[4]
if(length >= 6) : scoredHG = output[5]
if(length >= 7) : scoredLG = output[6]
if(length >= 8) : numGear = output[7]
if(length >= 9) : numLG = output[8]
if(length >= 10) : numHG = output[9]
if(length >= 11) : climbed = output[10]
if(length >= 12) : matchNotes = output[11]
wbMatch = load_workbook(matchList)
wbTeam = load_workbook(teamList)
templateMatch = wbMatch.active
templateTeam = wbTeam.active
for sheet in wbMatch :
if(sheet.title == matchNum) :
countMatch = True
for sheet in wbTeam :
if(sheet.title == teamNum):
countTeam = True
if(not countMatch) :
wsMatch = wbMatch.copy_worksheet(templateMatch)
wsMatch.title = (matchNum)
print(wsMatch.title + " is not in MatchList.")
print(wbMatch.sheetnames)
elif(countMatch) :
wsMatch = wbMatch[matchNum]
print(wsMatch.title + " is in MatchList.")
print(wbMatch.sheetnames)
if(not countTeam) :
wsTeam = wbTeam.copy_worksheet(templateTeam)
wsTeam.title = (teamNum)
print(wsTeam.title + " is not in TeamList.")
print(wbTeam.sheetnames)
elif(countTeam) :
wsTeam = wbTeam[teamNum]
print(wsTeam.title + " is in TeamList.")
print(wbTeam.sheetnames)
print("Match List")
rowNumMatch = highestRow( wsMatch )
print("Team List")
rowNumTeam = highestRow( wsTeam )
wsMatch[startCol + str(rowNumMatch)].value = teamNum
wsTeam[startCol + str(rowNumTeam)].value = matchNum
wsMatch['B' + str(rowNumMatch)].value = alliance
wsTeam['B' + str(rowNumTeam)].value = alliance
wsMatch['C' + str(rowNumMatch)].value = startPosition
wsTeam['C' + str(rowNumTeam)].value = startPosition
wsMatch['D' + str(rowNumMatch)].value = placedGear
wsTeam['D' + str(rowNumTeam)].value = placedGear
wsMatch['E' + str(rowNumMatch)].value = scoredHG
wsTeam['E' + str(rowNumTeam)].value = scoredHG
wsMatch['F' + str(rowNumMatch)].value = scoredLG
wsTeam['F' + str(rowNumTeam)].value = scoredLG
wsMatch['G' + str(rowNumMatch)].value = numGear
wsTeam['G' + str(rowNumTeam)].value = numGear
wsMatch['H' + str(rowNumMatch)].value = numLG
wsTeam['H' + str(rowNumTeam)].value = numLG
wsMatch['I' + str(rowNumMatch)].value = numHG
wsTeam['I' + str(rowNumTeam)].value = numHG
wsMatch['J' + str(rowNumMatch)].value = climbed
wsTeam['J' + str(rowNumTeam)].value = climbed
wsMatch['K' + str(rowNumMatch)].value = matchNotes
wsTeam['K' + str(rowNumTeam)].value = matchNotes
wbMatch.save(matchList)
wbTeam.save(teamList)
return True
except Exception as e :
print(e)
return e