# 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/es/reference/steps/make-csv

## De un vistazo

| Propiedad | Valor |
| --- | --- |
| **Nombre del paso** | `make-csv` |
| **Recurso** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Grupo de la paleta, categoría** | files, tables |
| **Créditos** | **0.5** créditos cada vez que tiene éxito |
| **Efectos externos** | no |
| **La instalación debe aportar** | nada |

## Entradas

| Propiedad | Valor |
| --- | --- |
| **Necesita** | `fields` |
| **Produce** | `file` |
| **Trabaja sobre** | item: un documento cada vez |

Necesita y Produce son tipos de datos (file, text, fields, email). El editor ofrece un paso solo donde lo que necesita ya está en el camino. Consulta [Documentos y datos](https://docs.go-lumen.ai/es/concepts/how-flows-run.md#documents-and-data).

## Salidas

Sin salidas con nombre. Los nodos posteriores siguen viendo todo lo producido antes en el camino, y este paso pasa los documentos sin cambios.

## Ajustes

Se definen bajo `config:` en el nodo del flujo. Los ajustes de texto pueden contener marcadores de posición como `{nodeId.field}`.

| Ajuste | Tipo | Valor por defecto | Descripción |
| --- | --- | --- | --- |
| `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` (obligatorio) | 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. |

El JSON Schema completo de estos ajustes: [make-csv.schema.json](https://docs.go-lumen.ai/schemas/steps/make-csv.schema.json).

## Ejemplo

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

## Úsalo en un flujo

Un nodo que ejecuta `make-csv` va bajo `spec.nodes` de un [Flow](https://docs.go-lumen.ai/es/concepts/how-flows-run.md#the-flow-as-yaml). Dale cualquier id y enumera en next los ids de los nodos siguientes.

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