# impl1 · lee los 32 xlsx del PMP (zipfile + ElementTree) -> tmp/pmp_filas.parquet y control contra la fila global import glob, re, json, pyarrow as pa, pyarrow.parquet as pq import xlsx_et as X COD=re.compile(r'^\d\d-\d\d-\d\d\d-[A-Z]{1,2}-[A-Z]{1,2}-\d{3}$') rows=[]; ctl=[] for f in sorted(glob.glob('/pmp/descargas/eell_*.xlsx')): y,m=map(int,re.findall(r'eell_(\d+)_(\d+)',f)[0]); q=m//3 for hoja,mod in (('Cesión','cesion'),('Variables','variables')): s=0.0; n=0; glob_=None for r in X.filas(f,hoja): r=list(r)+[None]*12 c=str(r[3]).strip() if r[3] is not None else '' if COD.match(c): p=r[7] if isinstance(r[7],float) else None rows.append((y,q,mod,c,str(r[4]),str(r[5]).strip(),p,r[9] if isinstance(r[9],float) else None)) s+=p or 0; n+=1 elif r[4] and str(r[4]).startswith('EELL'): glob_=r[7] ctl.append(dict(anio=y,trim=q,modelo=mod,n=n,suma=round(s,2),global_pub=glob_,dif=round(s-(glob_ or 0),2))) t=pa.table({k:[r[i] for r in rows] for i,k in enumerate(['anio','trim','modelo','codigo','tipo_ent','nombre','pagos','pendientes'])}) pq.write_table(t,'/w/tmp/pmp_filas_impl1.parquet') json.dump(ctl,open('/w/salidas/10_lectura_vs_global.json','w'),ensure_ascii=False,indent=0) print('filas',len(rows),'max |dif| global',max(abs(c['dif']) for c in ctl)) print([c for c in ctl if abs(c['dif'])>1])