Browse Source

July 1 requested

master
sipp11 11 years ago
parent
commit
c2716fba03
  1. 13
      s1.py
  2. 22
      s4.py

13
s1.py

@ -25,7 +25,11 @@ def get_rank_thing(filename, **kwargs):
reader.next() reader.next()
for r in reader: for r in reader:
mn, rank_no = r[0], r[9] 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 = ( q = (
('A', r[1]), ('B', r[2]), ('C', r[3]), ('D', r[4]), ('A', r[1]), ('B', r[2]), ('C', r[3]), ('D', r[4]),
('E', r[5]), ('F', r[6]), ('G', r[7]), ('H', r[8]), ('E', r[5]), ('F', r[6]), ('G', r[7]), ('H', r[8]),
@ -36,7 +40,12 @@ def get_rank_thing(filename, **kwargs):
if result: if result:
# print(u'%s > %s' % (r[0], list(result))) # print(u'%s > %s' % (r[0], list(result)))
count += 1 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]: if rank_no not in model_count[mn]:
model_count[mn][rank_no] = set() model_count[mn][rank_no] = set()
model_count[mn][rank_no] = model_count[mn][rank_no].union(result) model_count[mn][rank_no] = model_count[mn][rank_no].union(result)

22
s4.py

@ -40,19 +40,37 @@ def get_weight(xmodel):
return result 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): def produce(match_all):
for ii in xmodels.keys(): for ii in xmodels.keys():
rows = [] rows = []
# prepare for data --> July 1 request
step_3_data = get_x_from_step3_all(ii)
weight = get_weight(ii) weight = get_weight(ii)
for lo in sorted(los.los): for lo in sorted(los.los):
is_matched = 1 if ii.lower() == los.los[lo]['model'].lower() else 0 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: try:
r += weight[lo] r += weight[lo]
rows.append(r) # this will append only LO w/ weight
except KeyError: except KeyError:
# print(ii, ' = ', is_matched, ' / ', lo) # print(ii, ' = ', is_matched, ' / ', lo)
pass pass
rows.append(r)
_f = '%s-step4.csv' % ii _f = '%s-step4.csv' % ii
create_csv(_f, rows, directory='part4') create_csv(_f, rows, directory='part4')

Loading…
Cancel
Save