# Module /csv

RFC 4180 CSV parser and serializer supporting tuple rows and header-mapped records.

```tangu
(use /csv)
```

## Functions & symbols

### read-records

`(read-records path [options]) -> (Array Map)`

Reads a CSV file with a header row and returns an Array of field-keyed Maps.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `path` | `String` | no | CSV file path |
| `options` | `Map` | yes | Optional {:delimiter ...} |

```tangu
(let rows (csv/read-records "./users.csv"))
```

### read-tuples

`(read-tuples path [options]) -> (Array Array)`

Reads CSV rows into an Array of string Arrays.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `path` | `String` | no | CSV file path |
| `options` | `Map` | yes | Optional {:has-headers Bool :delimiter ...} |

```tangu
(let rows (csv/read-tuples "./matrix.csv"))
```

### write-tuples

`(write-tuples path rows [options]) -> None`

Writes positional row Arrays (and optional header row) to a CSV file on disk.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `path` | `String` | no | Destination CSV file path |
| `rows` | `Array` | no | Array of row Arrays |
| `options` | `Map` | yes | Optional {:headers Array :delimiter ...} |

```tangu
(csv/write-tuples "./out.csv" [["Ada" 10] ["Grace" 20]])
```
