-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDAF_number.py
98 lines (89 loc) · 3.29 KB
/
DDAF_number.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
# install openpyxl
# download DDAF as .xlsx
# consolidate original (remove empty lines)
# add new sheets named "number", "b-b", and "b-m"
# finish "total" rows using AutoSum in Excel
# code the number for all trials
# and code b-b b-m for simple cases (1 machine & 1 block)
from openpyxl.workbook import Workbook
from openpyxl.worksheet.table import Table, TableStyleInfo
from openpyxl import load_workbook
# load the workbook named DDAF_original.xlsx
DDAF_original = load_workbook('DDAF_original.xlsx')
# source of original data worksheet named original
original = DDAF_original['original']
############################ number ####################################
######## counts if the number of blocks is exactly 2 (1 for True) #######
# output worksheet named number
number = DDAF_original['number']
# if data contains one "&", indicating two blocks used
# then return 1, else return 0
for i in range(2, 35):
for j in range(4, 80):
nmb = number.cell(row=i, column=j)
if nmb.value == None:
nmb = nmb
elif nmb.value.count('&') == 1:
nmb.value = 1
else:
nmb.value = 0
# ############################# block-block ############################
# ########## right(1)/wrong(0.5) match divided by no. relations ###########
# # output worksheet named bb
# bb = DDAF_original['b-b']
#
# # if data contains only one "::" and no "&", indicating only one block is used
# # then return 0
# # else ... (future TODO or hand code data)
# for i in range(2, 35):
# for j in range(4, 80):
# bbMatch = bb.cell(row=i, column=j)
# if bbMatch.value == None:
# bbMatch = bbMatch
# elif bbMatch.value.count('::') == 1 and bbMatch.value.count('&') == 0:
# bbMatch.value = 0
# else:
# bbMatch = bbMatch
#
# ############################ block-machine ###########################
# ########## right(1)/wrong(0.5) match divided by no. block(s) ###########
# # output worksheet named bm
# bm = DDAF_original['b-m']
#
# # if data contains only one "::" and no "&", indicating only one block is used, then
# # if the 1st and the 6th character matches, then
# # if color rule C return 1, else return 0.5
# # else if the 2nd and the 7th character matches, then
# # if shape rule S return 1, else return 0.5
# # else return 0
# # else ... (future TODO or hand code data)
#
# for i in range(2, 35):
# for j in range(4, 80):
#
# ruleCell = bm.cell(row=i, column=2)
# rule = ruleCell.value[1]
# bmMatch = bm.cell(row=i, column=j)
#
# if bmMatch.value == None:
# bmMatch = bmMatch
#
# elif bmMatch.value.count('::') == 1 and bmMatch.value.count('&') == 0 and len(bmMatch.value) >= 7:
# str = bmMatch.value
# if str[0].lower() == str[5].lower():
# if rule == "C":
# bmMatch.value = 1
# else:
# bmMatch.value = 0.5
# elif str[1].upper() == str[6].upper():
# if rule == "S":
# bmMatch.value = 1
# else:
# bmMatch.value = 0.5
# else:
# bmMatch.value = 0
#
# else:
# bmMatch = bmMatch
# save the updated workbook
DDAF_original.save('DDAF_original.xlsx')