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)

Install

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.

Source Distribution

typedcsvsort-1.8.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file typedcsvsort-1.8.tar.gz.

File metadata

  • Download URL: typedcsvsort-1.8.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.2

File hashes

Hashes for typedcsvsort-1.8.tar.gz
Algorithm Hash digest
SHA256 372ec188ba2ed8db9792637f942cff7d9d40288c9703b897fd4fa5a3ae941fe9
MD5 88f67d861ab19f2dcd704185989d41d1
BLAKE2b-256 3031bafe5db06fc623907f66fa1a1d108646585dbfee5c263787e9e9f7a44e1f

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