pjjet
pjjet is a lightweight CLI and importable Python library that turns enterprise files into clean, token-optimized context for LLMs. It favours robustness over cleverness: bad input becomes a warning plus best-effort output, never a traceback.
text / logs · CSV / TSV · JSON / JSONL · DOCX
Installation
From a checkout (the normal route until the package is published on PyPI):
pip install -e ".[all]" # everything
pip install -e . # core only, stdlib-only
The optional extras are also installable individually once published:
pip install "pjjet[tokens]" # tiktoken for exact token counts
pip install "pjjet[csv]" # charset-normalizer for better encoding guesses
pip install "pjjet[docx]" # python-docx + defusedxml
Python 3.10+ is required. The core package is stdlib-only; heavy parsers live in extras.
Quickstart
pjjet report.docx --format md
pjjet data.csv --format md --max-tokens 4000
pjjet slides.json --front-matter
cat sales.csv | pjjet --type csv -
CLI reference
| Option | Description |
|---|---|
--format |
Output format: md (default), json-compact, yaml, text |
--table-style |
auto (default), markdown, csv, records (keyvalue is an alias) |
--max-tokens N |
Hard token budget; progressive strategies run until the body fits |
--front-matter |
Emit YAML front matter with source, type, tokens and warnings |
--strict |
Fail with exit code 1 instead of repairing or skipping |
--type |
Force a converter: text, csv, json, docx |
--budget |
full (default) or summary (column stats + sample) |
--token-backend |
auto (default), tiktoken, chars |
--out DIR |
Write one file per input into DIR |
--list-types |
List converters and exit |
--version |
Print the version |
Boolean flags also accept an explicit value: --front-matter=True, --strict=False.
Exit codes: 0 success (warnings allowed), 1 --strict failure, 2 usage or I/O error.
Library API
import pjjet
result = pjjet.convert("report.docx", format="md", front_matter=True, max_tokens=4000)
print(result.text) # rendered body (+ front matter)
print(result.warnings) # tuple of ConversionWarning
print(result.stats) # tokens, token_backend, blocks, converter, dropped
# Bytes, streams and stdin-like objects work too
pjjet.convert(data, name="report.csv")
pjjet.convert(open("a.json", "rb"), format="yaml")
pjjet.convert raises only for caller errors (TypeError for an unsupported source,
ValueError for a bad option or unknown type, OSError for a missing file), an unusable
explicit tokenizer, and ConversionError in strict mode.
What each converter guarantees
Text / logs
Detects BOMs and encodings, strips control characters, collapses whitespace runs and breadline runs, and keeps line structure inside a paragraph.
CSV / TSV
- Parses the whole file with a real CSV reader, including quoted newlines.
- Detects
, ; \t |from the content (and.tsvfrom the extension). - Reports ragged rows and pads them instead of truncating data.
- Never de-duplicates rows or filters "suspicious" rows: conversion must not change the data. Structural problems are warnings.
--budget summaryemits column type inference, row count and null rate plus a sample.
JSON / JSONL
- Parses the whole document; a single object becomes key/value pairs, an array of objects
becomes a table with the union of keys, an array of strings becomes a list, and anything
nested stays a lossless
Datablock for JSON/YAML output. - Reports duplicate keys and non-standard
NaN/Infinityconstants instead of hiding them. - JSONL skips only the invalid lines and says how many.
DOCX
- Document order is preserved (paragraphs and tables interleaved as authored).
- Headings, nested tables, inline hyperlinks (
[text](url)), footnotes and tracked changes. - Tracked insertions are accepted; tracked deletions are excluded, with a warning.
- The ZIP container is checked for zip-bomb sizes/ratios before parsing, and footnotes are
parsed with
defusedxmlwhen available.
Token optimization
--table-style auto picks per table: records for sparse data, Markdown for small tables,
compact CSV for large ones.
When --max-tokens N is exceeded, these strategies run in order until the rendered body
fits, and stats.dropped / front matter record what happened:
- Remove empty blocks and collapse consecutive duplicates
- Abbreviate long cell and value strings
- Sample oversized tables and key/value lists (with visible
[... N more]elisions) - Render tables as compact CSV
- Keep table headers only
- Drop whole trailing blocks
- Truncate the final block, closing any open code fence
Token counting uses tiktoken (o200k_base) when installed and the backend name is always
reported, because exact and heuristic counts differ.
Front matter
---
source: report.docx
type: docx
tokens: 2400
token_backend: tiktoken:o200k_base
warnings:
- "tracked-changes: 3 tracked change(s): insertions accepted, deletions ignored."
---
Development
python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check .
python -m mypy
License
GNU General Public License v3.0 only (GPL-3.0-only) — see LICENSE.
Metadata
Release files for pjjet 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pjjet-0.1.1.tar.gz | 69.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pjjet-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 124.0 kB
Release files / pjjet-0.1.1.tar.gz
| Download URL | pjjet-0.1.1.tar.gz |
|---|---|
| Size | 69.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e8309aeae3792f5a82b0ba349931644a95e72c56db1fa52cf58eddbc2e7393a
|
|
BLAKE2b-256 checksum How to use checksums |
60deb3050a1b5222b18ff5a6b8d6e506520863c2c71d1ed1eda697ad37252622
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / pjjet-0.1.1-py3-none-any.whl
| Download URL | pjjet-0.1.1-py3-none-any.whl |
|---|---|
| Size | 54.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20d3aa9d9a0e37714cbaa9cfd50624df9fbd595a3a95377c724f8fb21ff7c66a
|
|
BLAKE2b-256 checksum How to use checksums |
78d45b47a352f4ef028735eddfe9e1d11021b0573b8665018e926d6ce2cdcbe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for pjjet 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.