-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
104 lines (73 loc) · 2.12 KB
/
generator.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
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
from openpyxl import load_workbook
wb = load_workbook('in.xlsx')
wb.active = 1
sheet = wb.active
# namelist: n18-48
# primalnumbers: o18-48
# secondnumbers: p18-48
# codes: c5-32
# primary: d, e, f, g
# secondary: h, i, j
startnumber = 18
endnumber = 48
print(sheet['a1'].value)
primarylist= []
for i in range(18,49):
name = sheet['n'+str(i)].value
primaries = []
primarystudents = 0
for j in ['d', 'e', 'f', 'g']:
for k in range(5,33):
if(sheet[j+str(k)].value == name):
primaries.append(sheet['b'+str(k)].value)
primarystudents = primarystudents + sheet['k'+str(k)].value
print(name)
print(primaries)
tpl = (name, primaries, primarystudents)
primarylist.append(tpl)
secondarylist= []
for i in range(18,49):
name = sheet['n'+str(i)].value
secondaries = []
secondarystudents = 0
for j in ['h', 'i', 'j']:
for k in range(5,33):
if(sheet[j+str(k)].value == name):
secondaries.append(sheet['b'+str(k)].value)
secondarystudents = secondarystudents + sheet['k'+str(k)].value
print(name)
print(secondaries)
tpl = (name, secondaries, secondarystudents)
secondarylist.append(tpl)
wb.active = 0
sheet = wb.active
print("---------------------")
i=3
for tpl in primarylist:
print(tpl[0])
print(tpl[1])
sheet['a' + str(i)] = tpl[0]
j = 0
letters = ['d', 'e', 'f', 'g']
for code in tpl[1]:
curcell = letters[j] + str(i)
print("to " + curcell + ": " + code)
sheet[curcell] = code
j = j + 1
sheet['k' + str(i)] = tpl[2]
i = i + 1
i=3
for tpl in secondarylist:
j = 0
letters = ['h', 'i', 'j']
for code in tpl[1]:
curcell = letters[j] + str(i)
print("to " + curcell + ": " + code)
sheet[curcell] = code
j = j + 1
sheet['l' + str(i)] = tpl[2]
sheet['m' + str(i)] = tpl[2] + sheet['k' + str(i)].value
i = i + 1
wb.active = 2
sheet = wb.active
wb.save('in2.xlsx')