Skip to main content

Python module to split files fast and easy

Project description

Text File Splitter

CircleCI Issues Forks Stars

Python module to split text file easy and fast, without compromising memory using big files.

Installation

You can install text-file-splitter by running the following command:

pip install text-file-splitter

Or you can download direct from Github and install it manually.

Usage

Import the module and initialise it.

    from text_files_splitter import TextFilesSplitter, ListMetrics

    source_file = './src/test/files'
    file_name = 'test_csv.csv'
    max_size_file = 10
    file_type = 'csv'
    metric_units = ListMetrics.MB
    output_directory = './output'
    include_header = True
    file_suffix = 'file_example'

    file_splitter = TextFilesSplitter(source_file, file_name, max_size_file, file_type,
                                                ListMetrics.MB, output_directory, include_header, file_suffix)

    files_splitted = file_splitter.get_file_splitted()

The outcome of get_file_splitted() is a list of dict with the following details

files_splitted = [
    {
        "file_name": file_name,
        "path": output_directory,
        "file_size": file_size_in_bytes,
        "count": count
    }...
]


Files compatibility

  • csv

Test

To run a test of the clone the repository and follow the instructions

pip install -r requirements.txt
python -m unittest

Expected Outcome

the time may vary depending on your machine performance

Ran 1 test in 0.180s

OK

List of test created

  • csv

Requirements

  • Python 3.4 or newer

Code Standards

Following pylint standards

License

The MIT License (MIT). Please see License File for more information.

Contributions

Thanks to Gorka for all his contributions.

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

text-file-splitter-0.0.13.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file text-file-splitter-0.0.13.tar.gz.

File metadata

  • Download URL: text-file-splitter-0.0.13.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for text-file-splitter-0.0.13.tar.gz
Algorithm Hash digest
SHA256 4e94a85474f482c4b4c5e3da9d3ac0ba37685599de1dec6ac43e4fbcf85f290c
MD5 be1476437358dcf5953201823d55763c
BLAKE2b-256 561494940aab426939d964ab38d70059090b297adbd5118811d9b88f3ce11ca3

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