File size: 454 Bytes
24aaa76 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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])
|