Dataset Viewer
The dataset viewer is not available for this dataset.
Unexpected token '<', "<html> <h"... is not valid JSON

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Overview

Property Value
Source Project Gutenberg (English catalog)
Snapshot 2026-07-02-18-47-04
Total files 50871
Total Tokens (BPE) ~7.14 billion
Total directories 86522
Primary format Plain text (.txt)
Bulk format Parquet, JSONL

Repository Structure

.
├── app.py                                      # Application entry point
├── main.py                                     # Main pipeline / processing script
├── d.py                                        # Utility / downloader script
│
├── pg_dataset/
│   ├── pg_dataset.jsonl                        # Full dataset in newline-delimited JSON
│   └── pg_manifest.json                        # Manifest: metadata index for all entries
│
├── project-gutenberg-en_2026-06-04.parquet     # Columnar bulk export (Apache Parquet)
│
└── <N>/                                        # Sharded text files by Gutenberg ID
    └── <NN>/
        └── <NNN>/
            └── <book_id>/
                └── <book_id>-0.txt             # Raw plain-text file for each book

Sharding Scheme

Individual book files are stored under a hierarchical directory tree derived from their numeric Gutenberg ID. This prevents any single directory from holding an unmanageable number of entries and ensures fast filesystem lookups.

For example, book 9320 is stored at:

9/3/2/9320/9320-0.txt

Each leaf directory corresponds to one book. The -0 suffix in the filename follows the standard Project Gutenberg naming convention for the primary (unformatted) text edition.


Data Formats

Plain Text (<book_id>-0.txt)

Raw UTF-8 plain-text files as distributed by Project Gutenberg. Each file includes the Project Gutenberg header and license footer. Strip these as needed using standard markers:

*** START OF THE PROJECT GUTENBERG EBOOK ... ***
*** END OF THE PROJECT GUTENBERG EBOOK ... ***

JSONL (pg_dataset/pg_dataset.jsonl)

One JSON object per line. Each record contains the book text alongside metadata fields. Suitable for streaming ingestion into data pipelines.

{"id": "6ba31f5b-0386-4c9c-8375-97036be44b01", "title": null, "author": "Kate Douglas Wiggin", "language": "en", "release_date": null, "text_length_chars": 342490, "cleaned_text_length": 342387, "text": "NEW CHRONICLES OF REBECCA\n\nBy Kate Douglas Wiggin\n\n\n\n\nCONTENTS\n\n     First Chronicle\n     Jack O'Lantern\n\n     Second Chronicle\n     Daughters of Zion\n\n     Third Chronicle\n     Rebecca's Thought Book\n.......”"}

Manifest (pg_dataset/pg_manifest.json)

A JSON index mapping Gutenberg IDs to file paths and metadata. Use this to resolve a book ID to its location on disk without a filesystem scan.


Getting Started

Requirements

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Reading a single book

book_id = 1342  # Pride and Prejudice

path = f"{str(book_id)[0]}/{'/'.join(str(book_id)[1:-1])}/{book_id}/{book_id}-0.txt"
with open(path, encoding="utf-8") as f:
    text = f.read()

Loading the full corpus via Parquet

import pandas as pd

df = pd.read_parquet("project-gutenberg-en_2026-06-04.parquet")
print(f"Loaded {len(df):,} books")
print(df.columns.tolist())

Streaming from JSONL

import json

with open("pg_dataset/pg_dataset.jsonl", encoding="utf-8") as f:
    for line in f:
        record = json.loads(line)
        # process record

Using the manifest

import json

with open("pg_dataset/pg_manifest.json", encoding="utf-8") as f:
    manifest = json.load(f)

entry = manifest["1342"]
print(entry)  # {"path": "1/3/4/1342/1342-0.txt", "title": "...", ...}

License

The code in this repository is released under the MIT License.

The texts are sourced from Project Gutenberg and are in the public domain in the United States. Books may be subject to copyright restrictions in other jurisdictions. Consult the Project Gutenberg license terms and the header of each individual file before redistribution.

Project Gutenberg is a trademark of the Project Gutenberg Literary Archive Foundation. All usage must comply with the Project Gutenberg License.


Acknowledgements

Downloads last month
4,638