import csv, json, os B='cotejo/' rows=[r for r in csv.DictReader(open(B+'muestra_c.csv')) if r['clase']=='no_casada'] def s(v): if isinstance(v,dict): v=v.get('spa') or next(iter(v.values())) if isinstance(v,list): v=' | '.join(map(str,v[:6]))+(f' …(+{len(v)-6})' if len(v)>6 else '') return str(v) for i,r in enumerate(rows): f=B+f'resp/n{i:02d}_ft.json' print(f"== n{i:02d} {r['anio']} exp={r['expediente']} | {r['organo'][:50]} | {r['objeto'][:90]} | {r['adjudicatarios'][:30]} | {float(r['imp_sin'] or 0):,.0f} | fadj={r['fadj']} | lote={r['lote_id'][-6:]}") if not os.path.exists(f): print(' (misma consulta que otra)'); continue d=json.load(open(f)); print(' total', d.get('totalNoticeCount')) for n in d.get('notices',[])[:12]: print(f" {n.get('notice-type')} {n.get('publication-number')} {n.get('publication-date','')[:10]} exp={s(n.get('internal-identifier-proc',''))[:30]} | {s(n.get('buyer-name',''))[:40]} | {s(n.get('title-proc',''))[:70]} | win={s(n.get('winner-name',''))[:60]}")