diff --git a/s1.py b/s1.py index 6bfc36c..1426dc3 100755 --- a/s1.py +++ b/s1.py @@ -25,7 +25,11 @@ def get_rank_thing(filename, **kwargs): reader.next() for r in reader: mn, rank_no = r[0], r[9] - w = [r[10], r[11], r[12], r[13], r[14]] + w = [ + r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], # July 1 + rank_no, # July 1 + r[10], r[11], r[12], r[13], r[14] + ] q = ( ('A', r[1]), ('B', r[2]), ('C', r[3]), ('D', r[4]), ('E', r[5]), ('F', r[6]), ('G', r[7]), ('H', r[8]), @@ -36,7 +40,12 @@ def get_rank_thing(filename, **kwargs): if result: # print(u'%s > %s' % (r[0], list(result))) count += 1 - owriter.writerow([mn, ','.join(list(result)), rank_no] + w) + owriter.writerow([ + mn, + ','.join(list(result)), + len(result), + # rank_no + ] + w) if rank_no not in model_count[mn]: model_count[mn][rank_no] = set() model_count[mn][rank_no] = model_count[mn][rank_no].union(result) diff --git a/s4.py b/s4.py index 08558eb..d8734dd 100755 --- a/s4.py +++ b/s4.py @@ -40,19 +40,37 @@ def get_weight(xmodel): return result +def get_x_from_step3_all(m): + ''' + July 1 requested + ''' + fpath = os.path.join(os.getcwd(), 'build', 'part3', '%s-all.csv' % m) + los = {} + with open(fpath, 'rb') as f: + rows = csv.reader(f) + for r in rows: + for lo in r[1].split(','): + los[lo] = r[0] + return los + + def produce(match_all): for ii in xmodels.keys(): rows = [] + # prepare for data --> July 1 request + step_3_data = get_x_from_step3_all(ii) weight = get_weight(ii) for lo in sorted(los.los): is_matched = 1 if ii.lower() == los.los[lo]['model'].lower() else 0 - r = [lo, is_matched, los.los[lo]['weight']] + # [July 1] some lo doesn't have that data, blank then + july_1_col = step_3_data[lo] if lo in step_3_data else '' + r = [july_1_col, lo, is_matched, los.los[lo]['weight']] try: r += weight[lo] + rows.append(r) # this will append only LO w/ weight except KeyError: # print(ii, ' = ', is_matched, ' / ', lo) pass - rows.append(r) _f = '%s-step4.csv' % ii create_csv(_f, rows, directory='part4')