blokboard/ Open app

EXAMPLE 06 OF 16 · Starter

Read and transform a CSV

Create a sample CSV, read its rows, calculate totals, and inspect a new CSV. Everything runs locally in the browser.

BrowserFilesCSVJavaScript

Before you begin#

  • Use the Browser runtime. The workflow creates its own temporary file, so you need no local path, uploaded file, or credentials.

WORKFLOW SNAPSHOT

Read and transform a CSV

7 nodes

Interactive workflow preview loads here. Download the JSON to inspect it in the app.

Import creates an inactive copy. Set your own inputs and connections before running.

Opens as a new, inactive workflow. Review the nodes before running.

Walk through the workflow#

  1. Create file makes orders.csv from three lines of sample text. Inspect its Content field before running.
  2. Read file reads the entire file once. Parse CSV uses its text and treats the first row as column names.
  3. Code converts quantity and price from text to numbers, then returns one total per row.
  4. Write CSV creates totals.csv. The last Read file shows the generated CSV text while the temporary file is still available.
  5. Run once and inspect the final text: name,total followed by Notebook,10 and Pen,6.

Follow the data#

StepWhat the next node receives
Create fileA temporary file reference
Read fileAn object containing the complete CSV text
Parse CSVAn array of objects with text-valued cells
CodeAn array with name and numeric total fields
Write CSVA new temporary file reference
Final Read fileThe generated CSV text

Check your result#

name,total
Notebook,10
Pen,6

The important distinction is between a file reference, text, and row data. Each step turns one form into the next.

Make one change#

Add Folder,4,3 as a new line in Create file’s Content. Expect Folder,12 in the result. Read file must stay in all-lines mode so Parse CSV receives the full header and all rows together.

Save it on your device#

Choose Desktop and connect Save file after Write CSV. Select Write CSV’s output in File and enter an absolute destination path on the Desktop machine. The browser example deliberately ends by reading the generated text.

If it does not match#

If Parse CSV says it needs text, check that it follows Read file rather than Create file. If only one row is processed, check the reader’s mode. A temporary file reference from an earlier run cannot be reused: create or open the file again in the current run. See the complete Files guide.