Datasets:
Upload folder using huggingface_hub
Browse files- convert_to_parquet.py +44 -0
- full.parquet +3 -0
- lite.parquet +3 -0
convert_to_parquet.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Convert JSONL datasets to Hugging Face parquet format."""
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import pandas as pd
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def jsonl_to_parquet(jsonl_path: str, parquet_path: str) -> int:
|
| 10 |
+
"""Convert a JSONL file to parquet format."""
|
| 11 |
+
records = []
|
| 12 |
+
with open(jsonl_path, 'r') as f:
|
| 13 |
+
for line in f:
|
| 14 |
+
line = line.strip()
|
| 15 |
+
if line:
|
| 16 |
+
records.append(json.loads(line))
|
| 17 |
+
|
| 18 |
+
df = pd.DataFrame(records)
|
| 19 |
+
df.to_parquet(parquet_path, index=False)
|
| 20 |
+
return len(df)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def main():
|
| 24 |
+
base_dir = Path(__file__).parent
|
| 25 |
+
|
| 26 |
+
# Convert lite split
|
| 27 |
+
lite_input = base_dir / "dataset.jsonl"
|
| 28 |
+
lite_output = base_dir / "lite.parquet"
|
| 29 |
+
lite_count = jsonl_to_parquet(lite_input, lite_output)
|
| 30 |
+
print(f"Converted {lite_count} records to {lite_output}")
|
| 31 |
+
|
| 32 |
+
# Convert full split
|
| 33 |
+
full_input = base_dir / "dataset_full.jsonl"
|
| 34 |
+
full_output = base_dir / "full.parquet"
|
| 35 |
+
full_count = jsonl_to_parquet(full_input, full_output)
|
| 36 |
+
print(f"Converted {full_count} records to {full_output}")
|
| 37 |
+
|
| 38 |
+
print("\nDone! Hugging Face dataset splits:")
|
| 39 |
+
print(f" - lite: {lite_output} ({lite_count} tasks)")
|
| 40 |
+
print(f" - full: {full_output} ({full_count} tasks)")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
main()
|
full.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d521242cc66c6659d11b25e4e114c7731c8ffaef97bc3550f9f49c77a6c53f59
|
| 3 |
+
size 143528
|
lite.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7666ab2611caf0205e87958f29f74a771779d4900dc678cff4b5e76ec0c7bb54
|
| 3 |
+
size 19066
|