turkic-ocr-code / scripts /r5_print /r5_print_schema.py
treoa's picture
Release 1
24aaa76
Raw History Blame Contribute Delete
454 Bytes
import sys
import pyarrow.parquet as pq
from huggingface_hub import HfFileSystem
fs = HfFileSystem()
p = sys.argv[1]
with fs.open(p, "rb") as f:
pf = pq.ParquetFile(f)
print(pf.schema_arrow)
print("row groups", pf.num_row_groups, "rows", pf.metadata.num_rows)
tb = pf.read_row_group(0, columns=[n for n in pf.schema_arrow.names if n != "text"])
d = tb.slice(0, 2).to_pydict()
for k, v in d.items():
print(k, str(v)[:200])