import csv, re, os # Run from workspace root. Independent recomputation in integer cents. offers = list(csv.DictReader(open('inputs/S2-store-offers.csv'))) specs = {r['sku']: r for r in csv.DictReader(open('inputs/S1-manufacturer-specs.csv'))} out = {r['offer_id']: r for r in csv.DictReader(open('output/comparison.csv', encoding='utf-8'))} assert set(out) == {o['offer_id'] for o in offers}, 'offer coverage mismatch' for o in offers: cents = (int(o['price_cad']) + int(o['shipping_cad'])) * 100 total = cents + (cents * 12 + 50) // 100 exp = '%d.%02d' % divmod(total, 100) got = out[o['offer_id']]['landed_total_cad'] print(o['offer_id'], exp, got, 'OK' if exp == got else 'MISMATCH') for k in ['ram_gb', 'ssd_gb', 'vram_gb']: assert out[o['offer_id']][k + '_S1'] == specs[o['sku']][k] print('1964.28*1.12 =', 196428 * 112 / 10000, '; 1964.29*1.12 =', 196429 * 112 / 10000) t = open('output/recommendation.md', encoding='utf-8').read() print('words:', len(t.split())) for c in sorted(set(re.findall(r'`([\w.-]+\.(?:csv|md|py))`', t))): print(c, 'exists' if os.path.exists('inputs/' + c) or os.path.exists('output/' + c) else 'MISSING') print('qualifying:', [k for k, v in out.items() if v['status'] == 'QUALIFIES']) print('columns:', len(next(iter(out.values()))))