Skip to main content

Sort large CSV files on disk rather than in memory

Project description

CSV Sort

For sorting CSV files on disk that do not fit into memory. The merge sort algorithm is used to break up the original file into smaller chunks, sort these in memory, and then merge these sorted files.

Example usage

>>> from csvsort import csvsort
>>> # sort this CSV on the 5th(str) and 3rd(int) columns (columns are 0 indexed)
>>> csvsort('test1.csv', [4,2], ["str", "int"])
>>> # sort this CSV with no header on 4th column and save results to separate file
>>> csvsort('test2.csv', [3], ["str"], output_file='test3.csv', has_header=False)
>>> # sort this TSV on the first column and use a maximum of 10MB per split
>>> csvsort('test3.tsv', [0], ["str"], max_size=10, delimiter='\t')
>>> # sort this CSV on the first column and force quotes around every field (default is csv.QUOTE_MINIMAL)
>>> import csv
>>> csvsort('test4.csv', [0], ["str"], quoting=csv.QUOTE_ALL)


Supports python 2 & 3:

$ pip install csvsort
$ pip3 install csvsort

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for typedcsvsort, version 1.8
Filename, size File type Python version Upload date Hashes
Filename, size typedcsvsort-1.8.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page