Datasets:
005 — Parquet Conversion & HuggingFace Dataset Card
Date: 2026-03-15
Scope: Convert 5 key TSV files to Parquet (ZSTD), add YAML dataset card for datasets library integration
1. Objective
Enable programmatic access via datasets.load_dataset("Nacryos/ancient-scripts-datasets", "config_name") by:
- Converting the 5 largest TSV files to Parquet format (columnar, compressed, typed)
- Adding a YAML frontmatter dataset card to
README.mdwith named configs pointing to the Parquet files - Preserving all original TSV files as legacy backups (no data removed)
Why Parquet?
- The HuggingFace
datasetslibrary v4.0 removed support for custom loading scripts (they causeRuntimeError). YAML-based configs pointing to Parquet files are the recommended replacement. - Parquet enables: columnar reads (load only needed columns), predicate pushdown (filter without full scan), proper null handling, typed schemas.
- TSV sentinel values (
-for missing data) are converted to proper nulls.
2. Scripts Used
| Script | Lines | Purpose |
|---|---|---|
scripts/convert_to_parquet.py |
~100 | Read TSV via pyarrow, force all columns to string on initial read, convert - sentinels to null, cast typed columns (int/float), write Parquet with ZSTD compression |
Key Implementation Details
- Type safety: All columns initially read as
pa.string()to avoid pyarrow type inference issues (e.g., Score column auto-detected asdoubleconflicting with-sentinel) - Null handling: All
-values converted to proper Parquet nulls viapc.if_else(pc.equal(col, "-"), None, col) - Compression: ZSTD (Zstandard) — best compression ratio for this data profile
- Column casting: Int columns (Tree_Distance, MRCA_Depth) cast to
pa.int32(), float columns (Score) cast topa.float64()
3. Data Sources
No new external data. This change only converts existing TSV files already in the dataset.
Input Files (preserved as legacy)
| File | Rows | TSV Size |
|---|---|---|
cognate_pairs_inherited.tsv |
22.9M | 2.2 GB |
cognate_pairs_similarity.tsv |
465K | 49.9 MB |
cognate_pairs_borrowing.tsv |
17K | 1.9 MB |
phylo_pairs.tsv |
386K | 24.7 MB |
languages.tsv |
1,177 | 39.3 KB |
4. Source Reputability
N/A — format conversion only, no new external data. All data integrity preserved from source TSVs.
5. Methodology
Conversion Process
- Read TSV with
pyarrow.csv.read_csv(), forcing all columns topa.string()schema - For each column, replace
-sentinel withnull - Cast numeric columns to proper types (
int32,float64) - Write Parquet with
pq.write_table(table, path, compression='zstd')
YAML Dataset Card
Added to README.md frontmatter:
configs:
- config_name: cognate_pairs_inherited
data_files:
- split: train
path: data/training/cognate_pairs/cognate_pairs_inherited.parquet
- config_name: cognate_pairs_borrowing
data_files:
- split: train
path: data/training/cognate_pairs/cognate_pairs_borrowing.parquet
# ... (5 total configs)
Why NOT a Loading Script
HuggingFace datasets v4.0 (released late 2025) removed custom loading script support entirely. Any repo with a *.py loading script triggers RuntimeError. YAML-based configuration is the official replacement.
6. Tests Performed
- Row count verification: Each Parquet file verified to have identical row count to source TSV
- Schema verification: Column names and types match expected schema
- Random sample verification: 10 random rows from each Parquet file compared byte-for-byte against corresponding TSV rows
- Null handling: Verified
-sentinels are proper nulls (not empty strings) in Parquet - LFS integrity: Verified no LFS pointer files were accidentally converted (detected and re-pulled
cognate_pairs_borrowing.tsvwhich was a 3-line LFS pointer) - HuggingFace API verification: Confirmed
https://huggingface.co/api/datasets/Nacryos/ancient-scripts-datasetsreturns all 5 configs
7. Cross-Referencing
- Parquet file sizes verified to be strictly smaller than TSV (compression working correctly)
- Column count matches: 14 columns for cognate pairs, 9 for phylo_pairs, 5 for languages
- HuggingFace Dataset Viewer activated and showing data correctly
8. Output Summary
| File | TSV Size | Parquet Size | Compression Ratio |
|---|---|---|---|
cognate_pairs_inherited.parquet |
2.2 GB | 23.6 MB | 93.8x |
cognate_pairs_similarity.parquet |
49.9 MB | 5.0 MB | 10.0x |
cognate_pairs_borrowing.parquet |
1.9 MB | 487 KB | 4.0x |
phylo_pairs.parquet |
24.7 MB | 416 KB | 59.3x |
languages.parquet |
39.3 KB | 13.7 KB | 2.9x |
| Total | 2.28 GB | 29.5 MB | 77.2x |
9. Legacy Preservation
All original TSV files are preserved in their original locations. The Parquet files are stored alongside them:
data/training/cognate_pairs/cognate_pairs_inherited.tsv(original, kept)data/training/cognate_pairs/cognate_pairs_inherited.parquet(new, added)
No data was removed or modified. The Parquet files are a read-optimized mirror.
10. SDK Package
A companion Python SDK (ancient-scripts-data) was also created in a separate repo (Project-Phaistos/ancient-scripts-datasets-NEW) to provide typed APIs for accessing this data. See that repo's README for API documentation.