|
|
@ -14,17 +14,11 @@ xmodels = { |
|
|
|
'CFSf': {}, 'CFSD': {}, 'CFHf': {}, 'CFHD': {}, 'PMSf': {}, 'PMSD': {}, |
|
|
|
'CFSf': {}, 'CFSD': {}, 'CFHf': {}, 'CFHD': {}, 'PMSf': {}, 'PMSD': {}, |
|
|
|
'PMHf': {}, 'PMHD': {}, 'PFSf': {}, 'PFSD': {}, 'PFHf': {}, 'PFHD': {}, |
|
|
|
'PMHf': {}, 'PMHD': {}, 'PFSf': {}, 'PFSD': {}, 'PFHf': {}, 'PFHD': {}, |
|
|
|
} |
|
|
|
} |
|
|
|
rk_conv = { |
|
|
|
''' |
|
|
|
'I': ['4', '3', '2', ''], |
|
|
|
แก้ตรงนี้ >> RANK_ORDER << ถ้าจะเพิ่ม rank ใส่อะไรก็ใส่ไปตามลำดับ |
|
|
|
'P': ['4', '3', '2', ''], |
|
|
|
''' |
|
|
|
'C': ['4', '3', '2', ''], |
|
|
|
RANK_ORDER = ['1', '2', '3', '4'] |
|
|
|
'F': ['5', '4', '3', '2', ''], |
|
|
|
|
|
|
|
'M': ['5', '4', '3', '2', ''], |
|
|
|
|
|
|
|
'H': ['4', '3', '2', ''], |
|
|
|
|
|
|
|
'S': ['4', '3', '2', ''], |
|
|
|
|
|
|
|
'f': ['4', '3', '2', ''], |
|
|
|
|
|
|
|
'D': ['4', '3', '2', ''], |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fs = ('Case1_LS.csv', 'Case1_Gender.csv', 'Case1_Level.csv', 'Case1_SciF.csv') |
|
|
|
fs = ('Case1_LS.csv', 'Case1_Gender.csv', 'Case1_Level.csv', 'Case1_SciF.csv') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,11 +32,11 @@ def process_s2_data(): |
|
|
|
with open(os.path.join(os.getcwd(), 'build', f_name), 'rb') as f: |
|
|
|
with open(os.path.join(os.getcwd(), 'build', f_name), 'rb') as f: |
|
|
|
rows = csv.reader(f) |
|
|
|
rows = csv.reader(f) |
|
|
|
for r in rows: |
|
|
|
for r in rows: |
|
|
|
if r[0] in ('count', 'All Result'): |
|
|
|
if r[0] in ('rank_no', 'All Result'): |
|
|
|
step = r[0] |
|
|
|
step = r[0] |
|
|
|
rank = r[1] if r[0] == 'count' else '' |
|
|
|
rank = r[1] |
|
|
|
continue |
|
|
|
continue |
|
|
|
if step == 'count': |
|
|
|
if step == 'rank_no': |
|
|
|
if r[0] not in rank_result: |
|
|
|
if r[0] not in rank_result: |
|
|
|
rank_result[r[0]] = {} |
|
|
|
rank_result[r[0]] = {} |
|
|
|
rank_result[r[0]][rank] = r[1].split(',') |
|
|
|
rank_result[r[0]][rank] = r[1].split(',') |
|
|
@ -53,6 +47,7 @@ def process_s2_data(): |
|
|
|
# print('exists:', r[1], '|', step, '|', rank) |
|
|
|
# print('exists:', r[1], '|', step, '|', rank) |
|
|
|
pass |
|
|
|
pass |
|
|
|
sum_result[r[0]] = r[1].split(',') |
|
|
|
sum_result[r[0]] = r[1].split(',') |
|
|
|
|
|
|
|
# print(rank_result['C'].keys()) |
|
|
|
return { |
|
|
|
return { |
|
|
|
'sum': sum_result, 'rank': rank_result |
|
|
|
'sum': sum_result, 'rank': rank_result |
|
|
|
} |
|
|
|
} |
|
|
@ -71,46 +66,19 @@ def produce_s2_part1(sum_result): |
|
|
|
create_csv(_f, rows, directory='part2') |
|
|
|
create_csv(_f, rows, directory='part2') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def produce_s2_part2_old(rank_result): |
|
|
|
def produce_s2_part2(rank_result): |
|
|
|
# create xxxx-2.csv |
|
|
|
# create xxxx-2.csv |
|
|
|
for ii in xmodels.keys(): |
|
|
|
for ii in xmodels.keys(): |
|
|
|
rows = [] |
|
|
|
rows = [] |
|
|
|
# get rank count first |
|
|
|
for rank in RANK_ORDER: |
|
|
|
ro = set() |
|
|
|
# print(ii, ':rank:', rank) |
|
|
|
for rk in xrange(0, 4): |
|
|
|
rows.append(['Rank#%s' % rank, 'rank', rank]) |
|
|
|
for i in ii: |
|
|
|
|
|
|
|
if i not in rank_result: |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
ro = ro.union(set(rank_result[i].keys())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rank_no = 1 |
|
|
|
|
|
|
|
for rk in sorted(list(ro), reverse=True): |
|
|
|
|
|
|
|
# print(ii, ':', rk) |
|
|
|
|
|
|
|
rows.append(['Rank#%s' % rank_no, 'rank', rank_no, 'count', rk]) |
|
|
|
|
|
|
|
rank_no += 1 |
|
|
|
|
|
|
|
for i in ii: |
|
|
|
for i in ii: |
|
|
|
# find order |
|
|
|
|
|
|
|
if i not in rank_result: |
|
|
|
if i not in rank_result: |
|
|
|
continue |
|
|
|
continue |
|
|
|
if rk in rank_result[i]: |
|
|
|
if rank not in rank_result[i]: |
|
|
|
rows.append([i, ','.join(rank_result[i][rk])]) |
|
|
|
|
|
|
|
_f = '%s-2.csv' % ii |
|
|
|
|
|
|
|
create_csv(_f, rows, directory='part2') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def produce_s2_part2(rank_result): |
|
|
|
|
|
|
|
# create xxxx-2.csv |
|
|
|
|
|
|
|
for ii in xmodels.keys(): |
|
|
|
|
|
|
|
rows = [] |
|
|
|
|
|
|
|
for rk in xrange(0, 4): |
|
|
|
|
|
|
|
rank_no = rk + 1 |
|
|
|
|
|
|
|
# print(ii, ':rank:', rank_no) |
|
|
|
|
|
|
|
rows.append(['Rank#%s' % rank_no, 'rank', rank_no]) |
|
|
|
|
|
|
|
for i in ii: |
|
|
|
|
|
|
|
if not rk_conv[i][rk]: |
|
|
|
|
|
|
|
continue |
|
|
|
continue |
|
|
|
# print(i, '::', rk_conv[i][rk]) |
|
|
|
rows.append([i, ','.join(rank_result[i][rank])]) |
|
|
|
rows.append([i, ','.join(rank_result[i][rk_conv[i][rk]])]) |
|
|
|
|
|
|
|
_f = '%s-2.csv' % ii |
|
|
|
_f = '%s-2.csv' % ii |
|
|
|
create_csv(_f, rows, directory='part2') |
|
|
|
create_csv(_f, rows, directory='part2') |
|
|
|
|
|
|
|
|
|
|
|