Skip to main content

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

file_splitter_harsh-1.0.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

file_splitter_harsh-1.0.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file file_splitter_harsh-1.0.3.tar.gz.

File metadata

  • Download URL: file_splitter_harsh-1.0.3.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

Hashes for file_splitter_harsh-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a38c7a424f5f3c0c25e6ab328def4cc46aee991a0f4ec5c88e3eed952e560982
MD5 d401ed3b54abff7d0108e4dfd9fa6564
BLAKE2b-256 74a348c97fe7bc04fc024fae2ed52ca817dc9472475fbb21e7ec701ec325940a

See more details on using hashes here.

File details

Details for the file file_splitter_harsh-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for file_splitter_harsh-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ba2be7644005647ce3516b03a96b5d0a96032ef45e0dc4388a99fc3a89af039d
MD5 b65188ce682aaa8296c5feefc3edb9fb
BLAKE2b-256 dae8d2b371d6ce90fa0d2c9b87b3a440dcf71c08d1f5739cc808d97f3d3aba08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page