From ee3c5a2c1fdb07ec64519080ed05f68d6963ec82 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Sun, 8 Jun 2014 13:27:42 +0700 Subject: [PATCH] wip --- s2.py | 2 +- s3.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 s3.py diff --git a/s2.py b/s2.py index b4f1723..780c755 100755 --- a/s2.py +++ b/s2.py @@ -75,7 +75,7 @@ def produce_s2_part2(rank_result): rank_no = 1 for rk in sorted(list(ro), reverse=True): # print(ii, ':', rk) - rows.append(['Rank#%s' % rank_no, rk]) + rows.append(['Rank#%s' % rank_no, 'rank', rank_no, 'count', rk]) rank_no += 1 for i in ii: # find order diff --git a/s3.py b/s3.py new file mode 100755 index 0000000..1803d4a --- /dev/null +++ b/s3.py @@ -0,0 +1,57 @@ +# -*- coding:utf-8 -*- +#!/usr/bin/env python +from __future__ import print_function +from base import Lo, create_csv +import os +import csv +import sys + +los = Lo() + +xmodels = { + 'IMSf': {}, 'IMSD': {}, 'IMHf': {}, 'IMHD': {}, 'IFSf': {}, 'IFSD': {}, + 'IFHf': {}, 'IFHD': {}, 'CMSf': {}, 'CMSD': {}, 'CMHf': {}, 'CMHD': {}, + 'CFSf': {}, 'CFSD': {}, 'CFHf': {}, 'CFHD': {}, 'PMSf': {}, 'PMSD': {}, + 'PMHf': {}, 'PMHD': {}, 'PFSf': {}, 'PFSD': {}, 'PFHf': {}, 'PFHD': {}, +} +fs = ('Case1_LS.csv', 'Case1_Gender.csv', 'Case1_Level.csv', 'Case1_SciF.csv') + + +def process_s2_data(): + xm_data = {} + for ii in xmodels.keys(): + fname = '%s-2.csv' % ii + fpath = os.path.join(os.getcwd(), 'build', 'part2', fname) + with open(fpath, 'rb') as f: + rows = csv.reader(f) + rank = 0 + for r in rows: + if r[1] == "rank": + rank = r[2] + continue + if ii not in xm_data: + xm_data[ii] = {} + if rank not in xm_data[ii]: + xm_data[ii][rank] = {} + xm_data[ii][rank] = r[1].split(',') + return xm_data + + +def produce_match_all(xdata): + for ii in xmodels.keys(): + los = set() + for _rank in xdata[ii]: + print(_rank) + + +def main(*argv): + xm = process_s2_data() + print(xm['CMHf'].keys()) + produce_match_all(xm) + pass + +if __name__ == '__main__': + if len(sys.argv) > 1: + main(sys.argv[1:]) + else: + main()