Skip to main content
# EZCSV

Some utility functions to do the obvious things you want to do with CSV files.

`csv` is easy, this is EZ.

Install it: `pip install ezcsv`

Definitely works with Python 3+.

It's on it's way towards compatability with Python 2.6+.

It's hard to say anything about it difinitively because there are no tests.

Please see "Contributing" below.


## Reference

#### `read_dicts(file_path)`

Returns the data at `file_path` as a list of dicts.

- **`file_path`** `string | Path`

#### `read_lists(file_path)`

Returns the data at `file_path` as a list of lists. Ignores blank lines.

- **`file_path`** `string | Path`

Example Usage:
```
>>> from easycsv import csv_as_list
>>> filepath = 'C:\\path\\to\\file.csv'
>>> print(filepath)
C:\path\to\file.csv
>>> l = csv_as_list(filepath)
>>> print(l[0])
First,Line,Of,File,Prints,Here
```

#### `write_dicts(data, csv_path, mkdir=False, silent_fail=False, fieldnames=None, encoding='utf-8', **kwargs)`

Writes the input data to a CSV file

Always produces a Unix-style CSV file, regardless of whether on
Windows or not.

- **`data`** `list[dict]`

One dict per line. The first dict is expected to contain all of the
keys that will form the header line, unless `fieldnames` is provided.
- **`csv_path`** `string | Path`

Should have a .csv extension. `mkdir` will malfunction if it doesn't.
- **`mkdir`** `bool`

If true, creates the directory tree leading up to `csv_path`, ignoring
if directories already exist. Default: `False`
- **`silent_fail`**: `bool`

If `true`, causes the method to do nothing if `data` happens
to be empty. Default: `False`
- **`fieldnames`**: `list[str]`

If set, provides the list of field names to be passed to `csv.DictWriter`.
These are written as the header, regardless of what keys are present in
the first dict in `data`. Default: `None`
- **`encoding`**: `str`

The encoding to write with. Default: 'utf-8'

- **`kwargs`**: `dict`

Passed on to `csv.DictWriter`. Cannot include `fieldnames`.

#### `write_lists(data, csv_path, mkdir=False)`

Writes the input data to a CSV file

Always produces a Unix-style CSV file, regardless of whether on
Windows or not.

- **`data`** `list[list]`

- **`csv_path`** `string | Path`

Should have a .csv extension. `mkdir` will malfunction if it doesn't.
- **`mkdir`** `bool`

If true, creates the directory tree leading up to `csv_path`, ignoring
if directories already exist.


## Contributing

This could really use some tests!

Feel free to fork and open a pull request. Please, one pull request per
functional change.



Metadata

Release files for ezcsv 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezcsv 0.3
File Size Uploaded Provenance Actions
ezcsv-0.3.tar.gz 3.1 kB Without provenance Details for ezcsv-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ezcsv 0.3
File Interpreter ABI Platform Actions
ezcsv-0.3-py3-none-any.whl Python 3 none any Details for ezcsv-0.3-py3-none-any.whl

Total release size: 8.5 kB

Release files / ezcsv-0.3.tar.gz

Download URL ezcsv-0.3.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
28210d0bb9fe7308b9592ae4cf1712a05138d27dc43aa082e36e3bad6ef81574
BLAKE2b-256 checksum
How to use checksums
0ed6f79124af4e9cf2a67fcfae09f640e2307a954d72de9eacc4eba1ea2d2610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

Release files / ezcsv-0.3-py3-none-any.whl

Download URL ezcsv-0.3-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03943f6ebd78d52ff8ce8cec9d9cd58049a70ff6ace9a2337d88176bb351bb75
BLAKE2b-256 checksum
How to use checksums
e733c7901276cca869609b595a08c4f84cc627bfe6bede4bce5e8f85df0abded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

Security for ezcsv 0.3

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.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page