blokboard/ Open beta

EXAMPLE 06 OF 8 · Starter

Read and transform a CSV

Read CSV rows, calculate totals, and append them to one output file in the browser.

BrowserFilesCSVJavaScript

Before you begin

  • Use the Browser runtime. This workflow creates both files in memory.

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 with sample rows. A second Create file prepares empty totals.csv.
  2. Read file selects orders.csv in CSV format. Each row starts one execution.
  3. Code calculates a total for that row. Write file appends the resulting object to totals.csv.
  4. Read file.done waits for all row paths. The final reader uses Custom to display the completed CSV text.

Follow the rows

Read file emits {name, quantity, price} once per CSV row. Code converts the numeric text and returns {name, total}. Write file appends each object to the same file.

The final text starts with name,total and includes Notebook,10 and Pen,6. Read file's row paths may overlap, so the two rows need not finish in input order. The final reader uses Custom to inspect the raw text; the first reader uses CSV to process row objects.

Make one change

Add Folder,4,3 to orders.csv. The result gains Folder,12. Add another key to the Code result and Write file adds its column to the header.

Sort or summarize before writing

Replace the Calculate-to-Write connection with Calculate, Merge, Code, then Write. Choose Collect items in Merge and also connect the first reader's done output to it. In the new Code node, use return input.sort((a, b) => b.total - a.total);. Move the final reader from the first reader's done output to Write's output. The writer runs once with the sorted array. Add Iterate after Merge when you need individual executions again. Turn off Flatten arrays in Merge when each incoming array should stay as its own batch.

Save the result

In Desktop, connect Save file to the first reader's done output. Select {{createdFile2.output}} and enter an absolute destination path. done waits for all writes, so the complete report is saved once. In the collected version above, connect Save after Write instead.

If it does not match

Create the output before reading rows, select the correct file reference in each node, and inspect the first failed execution. Temporary file references only work during their run. See the Files guide.