A simple Python library to split large text files into smaller parts.
Project description
file-splitter-harsh
A Python library to efficiently split large text files into smaller chunks — perfect for preprocessing large datasets, logs, or CSV files.
Installation
Install using pip:
pip install file-splitter-harsh
## Example
from filesplitter.splitter import FileSplitter
# Initialize the splitter
splitter = FileSplitter(
file_path="large_file.txt", # Path to the input file
lines_per_file=1000, # Number of lines per output file
output_dir="output", # Directory to save split files
file_prefix="chunk" # Prefix for output file names
)
# Start splitting the file
splitter.split()
| Parameter | Type | Default | Description |
| ---------------- | ---- | -------------- | ----------------------------------------------- |
| `file_path` | str | Required | Path to the input file |
| `lines_per_file` | int | `1000` | Number of lines each output file should contain |
| `output_dir` | str | `"output"` | Directory where output files will be saved |
| `file_prefix` | str | `"split_part"` | Prefix to use for each generated file name |
#Example Output
If your input file has 2500 lines and lines_per_file=1000, you'll get:
output/
-chunk_1.txt (1000 lines)
-chunk_2.txt (1000 lines)
-chunk_3.txt (500 lines)
Logging Example
2025-06-12 10:00:00 - INFO - File splitting complete! 3 files created in 'output'
Project details
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 file_splitter_harsh-1.0.2.tar.gz.
File metadata
- Download URL: file_splitter_harsh-1.0.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1401c7f244a00f94341774a83d3b57ba5c11feb3568e4a14ae18a58d824d9404
|
|
| MD5 |
e05b636dc763212ac0ea99930fd61157
|
|
| BLAKE2b-256 |
13d5e3ac1751280bca21babf6c7aaa429f29772fabc51f6f263738863c764d53
|
File details
Details for the file file_splitter_harsh-1.0.2-py3-none-any.whl.
File metadata
- Download URL: file_splitter_harsh-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d37450138593a476d5f3f231572fdd2c4a86aef7e5d21518cb3a4f72a40ab22b
|
|
| MD5 |
17accfa5d7ce8ab7067866d111c43b2c
|
|
| BLAKE2b-256 |
07fc6db549f7c7bdd9606f5dedfa0be157ba6bfc9cc5c4f9f355cbd6b00f8368
|