# Make a CSV file

> Turns a list of rows, for example the rows found in a spreadsheet, into a CSV file that opens in Excel.

Source: https://docs.go-lumen.ai/reference/steps/make-csv

## At a glance

| Property | Value |
| --- | --- |
| **Step name** | `make-csv` |
| **Resource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palette group, category** | files, tables |
| **Credits** | **0.5** credits each time it succeeds |
| **Side effects** | no |
| **Installation must provide** | nothing |

## Inputs

| Property | Value |
| --- | --- |
| **Needs** | `fields` |
| **Produces** | `file` |
| **Works on** | item: one document at a time |

Needs and Produces are data types (file, text, fields, email). The editor offers a step only where what it needs is already on the path. See [Documents and data](https://docs.go-lumen.ai/concepts/how-flows-run.md#documents-and-data).

## Outputs

No named outputs. Later nodes still see everything produced earlier on the path, and this step passes the documents on unchanged.

## Settings

Set under `config:` on the flow node. Text settings may contain `{nodeId.field}` placeholders.

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `from` | string |  | From is the field that holds the rows; rows (find-row's list) when unset. (minLength 1; maxLength 100) |
| `columns` | list of object |  | Columns are the columns to write, in order, with their headings. When unset every key the rows have is written, in the order they first appear (rowId first when the rows have one). (maxItems 200) |
| `columns[].name` (required) | string |  | Name is the key in each row (a sheet column's name). (minLength 1) |
| `columns[].title` | string |  | Title is the heading in the file; the name when unset. (maxLength 200) |
| `filename` | string |  | Filename names the file; it may hold `{fields}`. export.csv when unset. (maxLength 200) |
| `bom` | boolean | `true` | BOM starts the file with a UTF-8 byte order mark, which Excel needs to read Hebrew; on unless set to false. |

The full JSON Schema of these settings: [make-csv.schema.json](https://docs.go-lumen.ai/schemas/steps/make-csv.schema.json).

## Example

Turn three supplier rows into a CSV file

```yaml title="config"
columns:
- name: name
  title: Supplier
- name: city
  title: City
- name: status
  title: Status
filename: suppliers.csv
from: rows
```

## Use it in a flow

A node that runs `make-csv` goes under `spec.nodes` of a [Flow](https://docs.go-lumen.ai/concepts/how-flows-run.md#the-flow-as-yaml). Give it any id, and list the next node ids in next.

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: my-webhook
  namespace: tenant-acme
spec:
  classRef: {name: webhook}
  config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: make-csv-example
  namespace: tenant-acme
spec:
  displayName: "Make a CSV file"
  triggers:
    - id: start
      ref: {name: webhook-received}
      connectorRef: {name: my-webhook}
      next: [make-csv]
  nodes:
    - id: make-csv
      stepRef: {name: make-csv}
      config:
        columns:
        - name: name
          title: Supplier
        - name: city
          title: City
        - name: status
          title: Status
        filename: suppliers.csv
        from: rows
```
