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.5.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.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: file_splitter_harsh-1.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 3f48a416e55d402e67c29a86b2d7597db5f2566594b4d75c9cc35f413e2a4190
MD5 512f99a6c739cc001d2517f5ab3d4355
BLAKE2b-256 1806c36ab758d83cbb2832d7b12c7e6aa5ccb974f7fe494999d3a6e1fb719686

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for file_splitter_harsh-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cbf2b7bc7ece180c08f69b81efd58f0e16f97fd64c198e09e21068fe719ef0ff
MD5 8ab3d9b4adcb2e264bae7c0927a5bba2
BLAKE2b-256 7f85672dc3d157cd49d4afce8158321fe34a2b1c960890b57a27f2c6bce7c348

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