External sort
External sort algorithm implementation. External sorting is a class of sorting algorithms that can handle massive amounts of data. External sorting is required when the data being sorted do not fit into the main memory (RAM) of a computer and instead must be resided in slower external memory, usually a hard disk drive. Sorting is achieved in two passes. During the first pass it sorts chunks of data that each fit in RAM, during the second pass it merges the sorted chunks together. For more information see https://en.wikipedia.org/wiki/External_sorting.
Compatibility
ext-sort requires 3.6+.
Installation
You can install ext-sort with pip:
$ pip install ext-sort
Quick start
Quick start.
import csv
import io
import logging
import ext_sort as es
class CSVSerializer(es.Serializer):
def __init__(self, writer):
super().__init__(csv.writer(io.TextIOWrapper(writer, write_through=True)))
def write(self, item):
return self._writer.writerow(item)
class CSVDeserializer(es.Deserializer):
def __init__(self, reader):
super().__init__(csv.reader(io.TextIOWrapper(reader)))
def read(self):
return next(self._reader)
logging.basicConfig(
level=logging.DEBUG,
format='[%(levelname)-8s] %(asctime)-15s (%(name)s): %(message)s',
)
with open('/home/user/data.csv', 'rb') as unsorted_file, open('/home/user/data.sorted.csv', 'wb') as sorted_file:
# save the csv header
sorted_file.write(unsorted_file.readline())
es.sort(
reader=unsorted_file,
writer=sorted_file,
chunk_size=10_000_000,
Serializer=CSVSerializer,
Deserializer=CSVDeserializer,
workers_cnt=4,
)
Metadata
Release files for ext-sort 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ext-sort-0.2.0.tar.gz | 5.3 kB | Without provenance | Details for ext-sort-0.2.0.tar.gz |
Release files / ext-sort-0.2.0.tar.gz
| Download URL | ext-sort-0.2.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b877656b475c22a23decc2e1cdec073be9f7bf142259021f6df3ec20e5e56738
|
|
BLAKE2b-256 checksum How to use checksums |
da148bc09c1b4fba79885af0768510b89398d866866ede8717e03a9f04b230f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for ext-sort 0.2.0
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.