Files
Investidor-V2/outputs/investmoz-parques-mapa-20261016/prepare-matrix.py
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

14 lines
1.2 KiB
Python

from pathlib import Path
import csv,io,json,hashlib
csv.field_size_limit(10000000);out=Path(__file__).resolve().parent;root=out.parents[1];p=root/'docs/investmoz/v2/auditoria-portal/matriz-requisitos.csv';raw=p.read_bytes();s=raw.decode('utf-8-sig');lines=s.splitlines(keepends=True);r=csv.reader(io.StringIO(s,newline=''));h=next(r);start=r.line_num;chosen=[];total=0
ids={'M2-d0c06a75-0153','M2-d0c06a75-0186','MASTER-c71ec7ad-0007','MASTER-c71ec7ad-0010','MASTER-c71ec7ad-0012','MASTER-5dbf82c2-0049','MASTER-e1169a77-0100','MASTER-c71ec7ad-0002'}
for row in r:
total+=1;end=r.line_num
if row[0]in ids:chosen.append({'id':row[0],'row':row,'raw':''.join(lines[start:end])})
start=end
assert total==3402 and len(chosen)==8
digest=hashlib.sha256(raw).hexdigest();assert digest==json.loads((out/'BASELINE-APLICACAO.json').read_text('utf-8'))['matrix_before_sha256']
folder=out/'matrix-tool';folder.mkdir(exist_ok=True);(folder/'before.csv').write_bytes(raw)
(folder/'input.json').write_text(json.dumps({'matrix':str(p),'sha256_before':digest,'headers':h,'selected':chosen,'csv_subset':''.join(lines[:1])+''.join(x['raw']for x in chosen)},ensure_ascii=False),'utf-8')
print(json.dumps({'selected':len(chosen),'raw_other_rows':3394,'states_unchanged':True}))