<a id="dads-frameworkcsv"></a>

# @dads-framework/csv

Call `toCsv(rows, columns)` to export records with column headers. It produces comma-separated cells, LF line endings, and a final newline. A column selects a property by name, with nested paths such as `address.city` or `items[0]`.

<a id="try-it"></a>

## Try it

In a project using Node.js 22 or later, install the example dependencies.

```sh
npm install @dads-framework/csv
npm install -D tsx
```

Save this as `example.mts` and run `npx tsx example.mts`.

```ts
import { toCsv } from "@dads-framework/csv";

const csv = toCsv(
  [{ customer: { name: "River, Inc." } }],
  [{ key: "customer.name", header: "Customer" }],
);
process.stdout.write(csv);
```

The script prints the header and a quoted cell on separate lines.

```text
Customer
"River, Inc."
```

The starter applies its spreadsheet-safety policy to note text and passes the result to `toCsv`. [`apps/kit-workbench/domains/notes/server/exports.ts`](https://dadsframework.dev/docs/source/apps/kit-workbench/domains/notes/server/exports.ts)

<a id="use-it"></a>

## Use it

The column list controls the header names and order. Before exporting data that a spreadsheet may interpret as formulas, apply the application's policy for spreadsheet-safe values.

<a id="cell-values"></a>

## Cell values

The serializer quotes commas, quotes, and line breaks. Missing and null cells are blank. Booleans produce `1` or a blank, dates use epoch milliseconds, and structured values use JSON.

Canonical page: <https://dadsframework.dev/docs/package-csv>
