📂 splitxfiles
A simple and lightweight Python library and Command Line Interface (CLI) for splitting files into smaller parts based on line count (text files) or file size (any file).
Ideal for processing log files, datasets, backups, wordlists, and other large files.
✨ Features
- 📄 Split UTF-8 text files by line count
- 📦 Split any file by file size
- 🐍 Easy-to-use Python API
- 💻 Command Line Interface (CLI)
- 📁 Automatically creates output directories
- 📊 Optional progress output
- ✅ Cross-platform (Windows, Linux, macOS)
📦 Installation
Install from PyPI
pip install splitxfiles
Install from Source
git clone https://github.com/Lutfifakee-Project/splitxfiles.git
cd splitxfiles
pip install -e .
🖥 Requirements
- Python 3.6 or later
- Windows
- Linux
- macOS
🚀 Python Usage
Split Text File by Line Count
from splitxfiles import split_by_lines
split_by_lines(
input_path="data.txt",
output_path="output",
lines_per_file=100
)
Split File by Size
from splitxfiles import split_by_size
split_by_size(
input_path="archive.bin",
output_path="output",
size_bytes=1024 * 1024 # 1 MB
)
💻 Command Line Usage
Split by Line Count
splitxfiles input.txt -o output -l 100
Split by File Size
splitxfiles input.bin -o output -s 1048576
Quiet Mode
splitxfiles input.txt -l 100 -q
Display Help
splitxfiles --help
⚙ CLI Options
| Option | Description |
|---|---|
-l, --lines |
Split file by line count |
-s, --size |
Split file by size (bytes) |
-o, --output |
Output directory (default: split_output) |
-q, --quiet |
Disable progress output |
-h, --help |
Show help message |
📂 Output
Example directory:
output/
├── data_part_1.txt
├── data_part_2.txt
├── data_part_3.txt
└── data_part_4.txt
Output files are automatically named using the following format:
<original_filename>_part_<number>.<extension>
Example:
log_part_1.txt
log_part_2.txt
log_part_3.txt
📸 Example Output
📄 Splitting 1500 lines into 3 files...
📁 Output folder: output
--------------------------------------------------
✅ [1/3] data_part_1.txt (500 lines)
✅ [2/3] data_part_2.txt (500 lines)
✅ [3/3] data_part_3.txt (500 lines)
--------------------------------------------------
✅ Done! 3 files created successfully.
Note
The exact output may vary depending on the
verboseoption and future versions.
📚 API Reference
split_by_lines()
Split a UTF-8 text file into multiple smaller files based on the number of lines.
split_by_lines(
input_path,
output_path,
lines_per_file,
verbose=True
)
Parameters
| Parameter | Type | Description |
|---|---|---|
input_path |
str |
Path to the input text file |
output_path |
str |
Output directory |
lines_per_file |
int |
Maximum number of lines per output file |
verbose |
bool |
Show progress information (default: True) |
Returns
| Type | Description |
|---|---|
bool |
Returns True if the operation succeeds, otherwise False. |
split_by_size()
Split any file into multiple smaller files based on file size.
split_by_size(
input_path,
output_path,
size_bytes,
verbose=True
)
Parameters
| Parameter | Type | Description |
|---|---|---|
input_path |
str |
Path to the input file |
output_path |
str |
Output directory |
size_bytes |
int |
Maximum size of each output file (bytes) |
verbose |
bool |
Show progress information (default: True) |
Returns
| Type | Description |
|---|---|
bool |
Returns True if the operation succeeds, otherwise False. |
⚠ Error Handling
The functions return False when:
- The input file does not exist.
- The input file is empty.
- The specified line count is less than or equal to zero.
- The specified file size is less than or equal to zero.
- An unexpected exception occurs during processing.
🧪 Running Tests
Run all unit tests:
python -m unittest tests/test_split.py -v
📁 Project Structure
splitxfiles/
├── src/
│ └── splitxfiles/
│ ├── __init__.py
│ └── cli.py
│
├── tests/
│ └── test_split.py
│
├── README.md
├── LICENSE
├── pyproject.toml
├── setup.py
└── .gitignore
🚧 Future Plans
- Merge split files
- Progress bar
- Multi-threaded processing
- Compression support
- Progress percentage display
- Improved error reporting
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for splitxfiles 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 | Actions |
|---|---|---|---|---|
| splitxfiles-0.1.1.tar.gz | 7.4 kB | Without provenance | Details for splitxfiles-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| splitxfiles-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for splitxfiles-0.1.1-py3-none-any.whl |
Total release size: 13.0 kB
Release files / splitxfiles-0.1.1.tar.gz
| Download URL | splitxfiles-0.1.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5067bf766abbbca617db679a1511d7735b8007e2a426aee366582d5b6ae8da85
|
|
BLAKE2b-256 checksum How to use checksums |
11003379e16d903d35d11628dbc39c67b96cf04c634df0030d7cdd1eb1f9fa41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / splitxfiles-0.1.1-py3-none-any.whl
| Download URL | splitxfiles-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f30ff990538e0887c955464ce2e5ad92bf6cfc1955b8461641dd4be23c08a99
|
|
BLAKE2b-256 checksum How to use checksums |
716cfdaf1c313cea2a842a73a0244247c7e93a512de452a6e1e0a3e395253ea2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for splitxfiles 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.