Skip to main content

Functions to do obvious things with CSVs

Project description

# EZCSV

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

`csv` is easy, this is EZ.


## 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)`

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.
- **`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.

- **`silent_fail`**: `bool`

If `true`, causes the method to do nothing if `data` happens
to be empty.

#### `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.



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

ezcsv-0.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

ezcsv-0.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page