You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.7 KiB

11 years ago
# -*- 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):
11 years ago
rows = []
11 years ago
for ii in xmodels.keys():
los = set()
for _rank in xdata[ii]:
11 years ago
los = los.union(set(xdata[ii][_rank]))
rows.append([ii, ','.join(list(los))])
_f = 'step3_match_all.csv'
create_csv(_f, rows, directory='part3')
11 years ago
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()