Cordwainer
A better CSV library
Features
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.
E.g.:
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
Metadata
Release files for cordwainer 0.0.2
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 |
|---|---|---|---|---|
| cordwainer-0.0.2.tar.gz | 10.3 kB | Without provenance | Details for cordwainer-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cordwainer-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for cordwainer-0.0.2-py3-none-any.whl |
Total release size: 19.8 kB
Release files / cordwainer-0.0.2.tar.gz
| Download URL | cordwainer-0.0.2.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
565d08d7ab436bc178c53c646c0e708f5e60914a15193e429fca8a9ccd39978f
|
|
BLAKE2b-256 checksum How to use checksums |
5baa9791b0a0f85d29ea758000d5f4ba4bee1c9e64dd542841da665ca280dc36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / cordwainer-0.0.2-py3-none-any.whl
| Download URL | cordwainer-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a5c66aa0b8f5e0a95b20b6486626b03a952c79796dad320af6125d0863661d2
|
|
BLAKE2b-256 checksum How to use checksums |
75aeb02891770c526f2df03994b3a9df7bf5de732a4dbbf1e1df09862a57019f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cordwainer 0.0.2
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.