csvsort
Sort large CSV files on disk rather than in memory
What it is and what it does
csvsort is a utility for sorting CSV files that exceed available memory. It implements an external merge-sort algorithm: the original file is split into smaller chunks that fit in memory, each chunk is sorted independently, and then the sorted chunks are merged back together. The package supports custom delimiters (for TSV and other formats), column selection, header detection, and CSV quoting options.
The tool is designed for a specific, narrow use case: when you have a large CSV file on disk and need to sort it without loading the entire file into RAM. It has no runtime dependencies and is straightforward to use via a single function call. However, the package is aging—last released in 2020 with minimal recent activity—and Python version support is undocumented, creating uncertainty about compatibility with current Python releases.
Use it for:
- Sort a multi-gigabyte CSV export from a database without exhausting available memory.
- Organize log files or data dumps by timestamp or ID columns before downstream processing.
- Prepare large datasets for merge operations or deduplication that require sorted input.
- Sort TSV or other delimiter-separated files using the same merge-sort strategy.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Sorts large CSV files on disk using a merge-sort algorithm that breaks files into memory-manageable chunks, sorts them, and merges the results—useful when the entire file cannot fit in RAM.
Yes, if you have a specific need to sort a CSV file too large for memory and can tolerate the aging codebase. The package is simple, has no dependencies, and solves a narrow problem well. However, verify Python version compatibility before relying on it in production, and consider whether a database or streaming tool might be more appropriate for your workflow. The LGPL license is permissive for internal use but requires disclosure if you modify and distribute the library.
Install
csvsort on PyPI
pip
pip install csvsortuv
uv add csvsortpoetry
poetry add csvsortInstalling csvsort
Before you install
High install friction reported. The package is aging—last release was 2020-06-17, over 2249 days ago—and the repository shows minimal activity (14 stars, last commit 2025-05-11). No runtime dependencies, but the age and inactivity suggest limited ongoing maintenance.
License in practice
Licensed under LGPL (copyleft). You must disclose source code modifications and make the modified library available under the same license if you distribute it; static linking or vendoring may require legal review depending on your use case.
Quickstart
from csvsort import csvsort
# Sort test.csv on columns 4 and 2 (0-indexed)
csvsort('test.csv', [4, 2])
# Sort with custom output file and delimiter
csvsort('test.tsv', [0], output_filename='sorted.tsv', delimiter='\t', max_size=10)
Python support is unspecified in the package metadata; the description mentions Python 2 & 3 support, but no minimum version is declared.
Verify before relying
- Whether Python 2 support is still functional or if the package is effectively Python 3-only in practice.
- Current performance characteristics and memory efficiency on modern systems with large files.
- Whether the package handles edge cases like malformed CSV, special characters, or non-ASCII encodings reliably.
Package facts
| License | lgpl (copyleft) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 2,249 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 120,586/month — #12,017 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: csvsort-1.6.1.tar.gz
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
natsortnatsort provides natural sorting for strings…
permissive · top 1,000 on PyPI
pyucaImplements the Unicode Collation Algorithm to…
permissive · top 15,000 on PyPI
xlsx2csvConverts XLSX spreadsheet files to CSV format,…
permissive · top 5,000 on PyPI
django-admin-csvexportAdds a Django admin action that exports…
permissive · top 15,000 on PyPI
sort-linesAlphabetizes lines in files based on…
permissive · top 15,000 on PyPI
usortμsort sorts Python imports within detected…
permissive · top 5,000 on PyPI
csv-diffCompares two CSV, TSV, or JSON files and…
permissive · top 15,000 on PyPI
linear-tsvParses and writes tabular data in Linear TSV…
permissive · top 15,000 on PyPI
detect-delimiterDetects the delimiter character used in CSV,…
permissive · top 15,000 on PyPI
zope.sequencesortSorts sequences by multiple keys with support…
unclear · top 15,000 on PyPI