Spaces:
Sleeping
Sleeping
Download validation/inspect_template.py from kishankrish19/Vision: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/kishankrish19/Vision/resolve/main/validation/inspect_template.py
- Command line
-
hf download hf://spaces/kishankrish19/Vision/validation/inspect_template.py
-
curl -L -o inspect_template.py https://huggingface.co/spaces/kishankrish19/Vision/resolve/main/validation/inspect_template.py
1.09 kB
| from pathlib import Path | |
| from zipfile import ZipFile | |
| import xml.etree.ElementTree as E | |
| S='{http://schemas.openxmlformats.org/spreadsheetml/2006/main}' | |
| p=Path('sources/MOM_Technical Report on 15-09-2026.xlsx') | |
| with ZipFile(p) as z: | |
| print(z.read('xl/workbook.xml').decode()[:4500]) | |
| strings=[''.join(n.itertext()) for n in E.fromstring(z.read('xl/sharedStrings.xml')).findall(S+'si')] | |
| for path in ['xl/worksheets/sheet1.xml','xl/worksheets/sheet2.xml']: | |
| root=E.fromstring(z.read(path));rows=root.find(S+'sheetData').findall(S+'row') | |
| print('\nSHEET',path,'rows',len(rows),'merges',[(n.attrib) for n in root.findall(S+'mergeCells/'+S+'mergeCell')][:20]) | |
| records=[] | |
| for row in rows: | |
| vals=[] | |
| for c in row: | |
| v=c.find(S+'v') | |
| if v is not None:vals.append((c.get('r'),strings[int(v.text)] if c.get('t')=='s' else v.text,c.get('s'))) | |
| if vals:records.append((row.get('r'),vals)) | |
| print('HEAD',records[:15]);print('TAIL',records[-15:]) | |
| print('EXTRAS',[(n.tag.split('}')[-1],E.tostring(n).decode()[:1100]) for n in root if n.tag!=S+'sheetData' and n.tag!=S+'mergeCells']) | |