CLI tool to split JSONL archive files by Jalali boundary date.
Project description
JSONL Archive Splitter
A production-ready Python CLI tool for splitting large JSONL archive files based on a Jalali (Persian) boundary date and configurable maximum file size.
Designed for memory efficiency, clean architecture, and extensibility.
✨ Features
- Split JSONL files based on
publish_ts - Supports Jalali (Shamsi) boundary dates
- Automatic file rotation by maximum size
- Line-by-line processing (memory efficient)
- Modular architecture (CLI / Core / Utils separation)
- Logging-based execution (no noisy prints)
- Ready for packaging and future PyPI publishing
📁 Project Structure
jsonl-archive-splitter/
│
├── src/
│ └── jsonl_archive_splitter/
│ ├── __init__.py
│ ├── __main__.py
│ ├── cli.py
│ ├── splitter.py
│ └── utils.py
│
├── requirements.txt
├── README.md
└── .gitignore
📦 Installation
Clone the repository:
git clone https://github.com/yourusername/jsonl-archive-splitter.git
cd jsonl-archive-splitter
Install dependencies:
pip install -r requirements.txt
requirements.txt:
jdatetime
🚀 Usage
Run from the project root directory:
python -m src.jsonl_archive_splitter --src-dir input --before-dir out_before --after-dir out_after --boundary-date 1404-07-30 --start 1 --end 10 --max-size 400
🧾 CLI Arguments
Argument Description
--src-dir Directory containing input JSONL files
--before-dir Output directory for messages up to boundary date
--after-dir Output directory for messages after boundary date
--boundary-date Jalali date in format YYYY-MM-DD
--start Start file index
--end End file index
--max-size Max size per output file in MB (default: 400)
🧠 How It Works
- Converts Jalali boundary date to Gregorian.
- Computes timestamp for 23:59:59 of boundary date.
- Iterates over JSONL files sequentially.
- Routes messages based on
publish_ts. - Rotates output files automatically when size limit is reached.
⚙️ Technical Design
- No global state
- Clear separation of concerns
- Logging instead of print statements
- Package-ready structure
- Easily extensible (e.g., Gregorian support, dry-run mode, progress bar)
🔮 Possible Future Improvements
- Add unit tests
- Add tqdm progress bar
- Add dry-run mode
- Add PyPI packaging (pyproject.toml)
- Add GitHub Actions CI
📄 License
MIT License
👤 Author
Saeed -- Software Engineer
Focused on clean architecture, scalable systems, and production-quality
tooling.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonl_archive_splitter-0.1.0.tar.gz.
File metadata
- Download URL: jsonl_archive_splitter-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d55f454593f1efa35a458543361864a84838da22595f13cb6c6cdc29be0715d
|
|
| MD5 |
816712cc7ac52b5081c3196db576de35
|
|
| BLAKE2b-256 |
db4ac7b071aab0d0fadc9bbcfa342bf9e364aa75ab20b313f391db229a6d26cf
|
File details
Details for the file jsonl_archive_splitter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jsonl_archive_splitter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80b62c09ca87af6dbe48566c824345a5ecc54ad73f2e77c55f0cee1a2958a2d
|
|
| MD5 |
ecccf3b5dfb87bb3715e693d0bb4c89a
|
|
| BLAKE2b-256 |
6d463c9d36f56259e1c486469d637cdc9b5b64c0362f9bb6e56d8a74dcde2b5a
|