Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

TransformExperimental

std:csv-decode #

Parses CSV text into records of strings.

For example: read a spreadsheet export as records.

A pipe is a data processing step with declared inputs and outputs; standard pipes are built into the runner.

Ports #

std:csv-decode takes in and produces out.std:csv-decodeintextoutrecords
std:csv-decode takes in and produces out.std:csv-decodeintextoutrecords
Named ports from the latest published contract. Dashed lines are optional ports.
Ports of std:csv-decode
PortDirectionKindRequiredDescription
ininputtextyes Media types: text/csv, text/plain; charset=utf-8
outoutputrecordsyes

Parameters #

Parameters of std:csv-decode
NameTypeDefaultRequiredDescription
headerbooleantrueno
delimiterstring","no
fieldsarraynonenoMember names when header is false.

When to use it #

  • A CSV file with a header row: every further row becomes a record with the header's names.
  • A file without a header, or with ; between fields: name the members with fields and set delimiter.

When to use something else

  • Every value arrives as a string, exactly as written — 007 stays "007". There is no type inference: follow with std:cast where you need numbers.

A tested example #

Nothing here is invented: this is the test “header row names the members and values stay strings” from the pipe's own portable test file, which every conformant runner must pass.

Parameters

This test sets no parameters.

Input: in
id,name
007,"Bond, James"
Expected output: out
{"id":"007","name":"Bond, James"}

The same step as a node of a pipeline.yaml:

pipeline.yaml
nodes:
  csv-decode:
    pipe: std:csv-decode
    inputs:
      in: {from: inputs.in}

This input is not plain records. A standalone pipeline.yaml cannot declare the kind of its inputs, so this node belongs in a pipe whose manifest declares the input in with kind text, or after a node that produces that kind.

Run it #

The pipe runs on its own from a shell. The input is the test input above. The quickstart shows how to get the openflange command.

Command
printf 'id,name\n007,"Bond, James"\n' | openflange run std:csv-decode
Standard output (out)
{"id":"007","name":"Bond, James"}

Executed with openflange 0.0.1 (go1.27.1 linux/amd64), built from commit 11cf8cc of the reference implementation; the output shown is what it printed, and it matches the test.

Notes from the manifest #

The pipe's manifest, OPENFLANGE.md, carries these notes.

Part of the OpenFlange standard library (std, version 0.1).

The explicit conversion from CSV text to records (it is never inserted automatically). Decoding is streaming. Quoting follows RFC 4180: quoted fields may contain the delimiter, doubled quotes ("") and line breaks. Rows end with LF or CRLF; a final row without a line terminator is accepted; a leading UTF-8 byte order mark is discarded. delimiter is exactly one character.

  • header: true (default): the first row names the members; every later row becomes an object with those members in header order. Duplicate or empty header names fail with E_FORMAT.
  • header: false with fields: fields names the members.
  • header: false without fields: every row becomes an array of strings.

Every value is a string, exactly as it appears after unquoting — nothing is type-guessed, so 007 and 1.50 arrive intact and an empty field is "". Use std:cast to convert members. A row whose number of fields differs from the header (or from fields) fails with E_FORMAT. Empty input, or only a header row, produces no records.

Limitations of this implementation: completely empty lines are skipped, and a CRLF inside a quoted field is read as LF.

Reference #

Maturity
Experimental
Processing scope
record
Manifest version
0.1.0