This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A better CSV library


  • Lets you program in both Python 2 and Python 3 as if you had the Python 3 CSV module.
  • Under Python 2, provides a Python 3 compatible csv module.
  • Under Python 3, passes through transparently.
  • Lets your CSV files be encoded any way you want.

Python 3 compatibility

import cordwainer.csv as csv ought to be equivalent to importing the Python 3 csv module, whether running with Python 2 or 3. See the Python 3 csv module documentation

CSV file encoding

The Python 2 csv module expects file handles passed to it to return data encoded in ASCII or UTF-8, and writes it to files the same way.

The Python 3 csv module expects handles passed to it to return text data, already decoded, and writes un-encoded text data to them. It’s your responsiblity to arrange for conversion when you open the file, or pipe your stream through some kind of conversion.

Using Cordwainer, you can just pass an extra encoding parameter to say that your stream is providing or expecting binary data with the specified encoding, and Cordwainer will take care of all necessary conversions.

If encoding is omitted or None, Cordwainer assumes the provided stream will provide or expect un-encoded text data, just like Python 3’s csv module.

Misc. Usage Notes

The encoding parameter is only applied for reading from and writing to streams.

String arguments should always be passed to the API as characters, and results are always characters.


  • Pass fieldnames to DictWriter as characters
  • Pass data in rows to writerow() as characters
  • next() returns rows in characters

Intended (eventually) features

  • Optional header row
  • Validate expected fields, types (probably specify a Django form to do the validation)
  • Verbose error handling - say what the problem was on what line, for every line that has an error
  • Optionally stop processing after N errors
  • Optionally import the lines that are valid while skipping invalid ones
  • Optionally do the whole thing in one transaction
  • Optionally ignore any extra columns
  • Optionally save uploaded file and then process it in a background task (to not delay the HTTP request)
  • For Excel, be flexible in deciding what sheet to import - or even import from multiple sheets from one upload
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cordwainer-0.0.2-py3-none-any.whl (9.5 kB) Copy SHA256 Checksum SHA256 py3 Wheel Jul 11, 2014
cordwainer-0.0.2.tar.gz (10.3 kB) Copy SHA256 Checksum SHA256 Source Jul 11, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting