nœuds / builtin / datatransformation
CSV
Convert between CSV text and items
Ce contenu n’est pas encore disponible dans votre langue.
Read CSV text into items, one per row, or turn items into CSV text.
Try it
Section titled “Try it”Page Table to CSV : un workflow de 4 étapes, qui commence par When Started et se termine par Copy to clipboard.
What it does
Section titled “What it does”CSV works in two directions, chosen with Operation:
- Parse into items reads CSV (or TSV) text and outputs one item per row, with the header names as field names. All values come out as text.
- Build from items takes all incoming items and writes them into one CSV text, one row per item.
It reads real-world CSV correctly: commas inside quoted values stay part of the value, a quoted value can span several lines, and "" inside quotes means one quote character. Messy files are handled rather than rejected:
- A short row leaves its missing columns empty. A long row keeps the extra values as
column4,column5and so on. - A repeated header name is made unique (a second
pricebecomesprice_2), and an empty header cell is named by position (column1). - An invisible byte order mark at the start of the file is removed, and both Windows and Unix line endings work.
When building, a value is quoted only when it needs it (it contains the delimiter, a quote, a line break, or leading or trailing spaces). Empty values become empty cells, and lists or objects are written as JSON. Columns are every field found across all items, in the order they first appear. Lines end with Windows line endings, which Excel expects.
When to use it
Section titled “When to use it”- Read a spreadsheet export or a CSV returned by an API into items you can filter and sort.
- Produce CSV text from scraped items, to save with Save as File or send in a message.
- To get a CSV file (for an upload or attachment) instead of text, use Convert to File with Format CSV.
Inputs and settings
Section titled “Inputs and settings”| Réglage | Type | Ce que cela fait |
|---|---|---|
| Operation | Choice | Which direction to convert. Options: Parse into items, Build from items. Par défaut : Parse into items |
| CSV Text | Value | The CSV to parse. Leave empty to read from a field instead. |
| Source Field | Text | Field holding the CSV text, when the field above is left empty. |
| Delimiter | Choice | Character separating the fields. Options: Comma, Semicolon, Tab, Pipe. Par défaut : Comma |
| First Row Is A Header | Toggle | Whether the first row names the columns. Par défaut : On |
| Write A Header Row | Toggle | Whether the built CSV starts with a row naming the columns. Par défaut : On |
| Columns | Tags | Columns to write, in order. Left empty, every field is written. |
| Trim Fields | Toggle | Remove surrounding whitespace from every parsed value. Par défaut : Off |
| Skip Blank Rows | Toggle | Drop rows that are entirely empty. Par défaut : On |
| Quote Every Field | Toggle | Quote every field, not only those that need it. Par défaut : Off |
| Add Byte Order Mark | Toggle | Write the mark Excel needs to read UTF-8 correctly. Par défaut : Off |
| Put CSV In Field | Text | Name of the field holding the built CSV text. Par défaut : csv |
- For parsing: put the text in CSV Text (for example
{{ $input.body }}), or leave it empty and name the field that holds it in Source Field. Turn off First Row Is A Header when the file has no header; the columns are then namedcolumn1,column2and so on. - For building: Columns picks which fields to write and in what order. Write A Header Row, Quote Every Field, Add Byte Order Mark and Put CSV In Field apply only here.
- Choose Tab in Delimiter for TSV, and Semicolon for many European Excel exports.
Outputs
Section titled “Outputs”-
Output
- Parse into items outputs one item per data row, such as
{ "name": "Ada", "city": "London" }. A file with only a header gives no items, not an error. - Build from items outputs one item with the CSV text in Put CSV In Field, read downstream with
{{ $input.csv }}.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- HTML Extract reads a table of products from a page, one item per row.
- CSV with Operation Build from items, Columns
name,price,url, and Add Byte Order Mark on, since the file will be opened in Excel. - Save as File with Content
{{ $input.csv }}, File nameproductsand File type csv downloads the file.
Common issues
Section titled “Common issues”- “No CSV to parse. Fill in the CSV text, or name the field holding it on the incoming item.” Both CSV Text and Source Field are empty.
- “Field “…” does not hold CSV text on the incoming item.“ The field in Source Field is missing or is not text. Check its name in the previous node’s output.
- “No items to build CSV from. Connect a node that produces items.” Nothing reached the node when building.
- Everything lands in one column. The file uses another separator. Change Delimiter to Semicolon, Tab or Pipe.
- Accented letters look garbled in Excel. Turn on Add Byte Order Mark when building.
Recipes with this node
Section titled “Recipes with this node”Related nodes
Section titled “Related nodes”- Convert to File: produce a CSV file for uploads and attachments.
- Extract From File: read a CSV file that arrived as an attachment.
- Edit Fields: tidy fields before building.
- Sort: order rows after parsing.