Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

File split made easy for python programmers!

A python module that can split files of any size into multiple chunks, with optimum use of memory and without compromising on performance. The module determines the splits based on the new line character in the file, therefore not writing incomplete lines to the file splits. The file splits are numbered from 1 to n as follows

[filename]_1.ext, [filename]_2.ext, …., [filename]_n.ext

System Requirements

Operating System: Windows/Linux/Mac

Python version: 2.7 and above (Python 3 recommended)

Usage

The module is available as a part of PyPI and can be easily installed using pip

pip install filesplit

Create an instance of the FileSplit object by passing file path and split size as arguments.

from fsplit.filesplit import FileSplit

fs = FileSplit(file='path/to/file', splitsize=500000000, output_dir='/path/to/output directory/')
  • “file” and “splitsize” are required. “output_dir” is optional and defaults to current directory.

  • “splitsize” should be given in bytes.

With the instance created, any of the following methods can be invoked

split (include_header=False, callback=None)

Method that splits the file into multiple chunks. This method works in binary mode under the hood which keeps the formatting and encoding of splits as-is to that of the source which should be sufficient to handle any file types.

fs.split()

In case, if the file contains a header and if you want the header to be available in all of your splits, you can optionally set the flag “include_header” to True. By default it is set to False.

fs.split(include_header=True)

Also, you can pass a callback function (optional) [func (str, long, long)] that accepts three arguments - full path to the split, split file size (bytes) and line count. The callback function will be called after each file split.

def func(f, s, c):
    print("file: {0}, size: {1}, count: {2}".format(f, s, c))

fs.split(callback=func)

splitbyencoding (rencoding=“utf-8”, wencoding=“utf-8”, include_header=False, callback=None)

This method is similar to the above split() method, except that the file encoding of the splits can be explicitly specified. This is helpful if the file chunks has to be of specific encoding standard. This method accepts two additional arguments to that of the split() method

  • “rencoding” - encoding of the source file (default : ‘utf-8’)

  • “wencoding” - encoding of the output file chunks (default: ‘utf-8’)

Metadata

Release files for filesplit 1.0.4beta

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filesplit 1.0.4beta
File Size Uploaded Provenance Actions
filesplit-1.0.4beta.tar.gz 3.9 kB Without provenance Details for filesplit-1.0.4beta.tar.gz

Release files / filesplit-1.0.4beta.tar.gz

Download URL filesplit-1.0.4beta.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
990e6690da554ecf5546a8ebd49911c6445c8c787c4aec930068afe7a2bd3c66
BLAKE2b-256 checksum
How to use checksums
da968393091fd640fca0bc25fa29c53a3258482a93ce3e54f1a528cae622c9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for filesplit 1.0.4beta

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page