CSV → JSON in a FUNC space
A deterministic pipeline with explicit routing and persistence.
@csvTransform:FUNC
>>> Converts incoming CSV files to JSON and stores them in a dataspace.
>>> On incoming work, run $func_main to determine the next step.
>
$func_main
>>> If the task hint is "load", use $loadCSV to read the CSV into rows.
>>> If the task hint is "convert", use $convertRows to turn rows into JSON.
>>> If the task hint is "persist", use $data_writer to store the JSON blob at "/processed/file.json".
>>> For anything else, use $fallback with the original work.
>
$loadCSV(in=%csvPath, out=%rows)
>>> Reads a CSV file from the given path into rows.
>
$convertRows(in=%rows, out=%jsonBlob)
>>> Normalises header names and encodes rows as JSON.
>
$data_writer(in=%jsonBlob, path="/processed/file.json")
>>> Writes the JSON output to the specified DATA path (path is mandatory).
>
$fallback
>>> Logs an error and emits an unroutable-work event before dropping the request.
What this shows
Deterministic three-stage pipeline. $func_main cleanly encodes load → convert → persist with explicit routing for each stage. No hidden control flow.
Each step is isolated. $loadCSV and $convertRows are independent and reusable in other :FUNC spaces. Dependencies between stages are visible in the data resources they exchange.
Durable output through :DATA only. Persistence flows through $data_writer with a fully qualified path= — required by the compiler. The persistence target is auditable at a glance.
$fallback keeps behaviour predictable. Every unsupported task hint has a defined behaviour, avoiding silent failures.
Multi-step file workflows without hidden state. The space encodes a small, file-oriented workflow that is easy to test, reproduce, and extend with new task hints.