Skip to content

Data

Convert and select small structured values across JSON, YAML, CSV, TSV, and text without spawning a shell.

action: data.convert reads inline data or a file, converts it, and writes the result to stdout. Use output: to capture the converted value for later steps.

action: data.pick reads inline data or a file, selects a value with a jq-style path, and writes the selected value to stdout.

Basic Usage

yaml
steps:
  - id: users_json
    action: data.convert
    with:
      from: csv
      to: json
      data: |
        name,age
        Alice,30
        Bob,25
    output: USERS_JSON

USERS_JSON contains:

json
[
  {
    "age": "30",
    "name": "Alice"
  },
  {
    "age": "25",
    "name": "Bob"
  }
]

Configuration

data.convert

FieldTypeRequiredDescription
fromstringYesInput format: json, yaml, csv, tsv, or text.
tostringYesOutput format: json, yaml, csv, tsv, or text.
dataanyOne of data or inputInline data to convert.
inputstringOne of data or inputFile path to read. Relative paths resolve against the step working directory.
has_headerbooleanNoWhether CSV/TSV input has a header row. Defaults to true.
headersbooleanNoInclude a header row for CSV/TSV output. Defaults to true.
columnsarrayNoColumn names for headerless CSV/TSV input or CSV/TSV output ordering.
delimiterstringNoSingle-character delimiter override.

data and input are mutually exclusive.

data.pick

FieldTypeRequiredDescription
fromstringYesInput format: json, yaml, csv, tsv, or text.
selectstringYesjq-style path to select, such as .spec.image or .[0].name.
dataanyOne of data or inputInline data to read.
inputstringOne of data or inputFile path to read. Relative paths resolve against the step working directory.
rawbooleanNoWrite selected scalar values without JSON/YAML encoding.
tostringNoOutput format: json, yaml, csv, tsv, or text. Defaults to json when raw is false.
has_headerbooleanNoWhether CSV/TSV input has a header row. Defaults to true.
headersbooleanNoInclude a header row for CSV/TSV output. Defaults to true.
columnsarrayNoColumn names for headerless CSV/TSV input or CSV/TSV output ordering.
delimiterstringNoSingle-character delimiter override.

raw and to are mutually exclusive.

CSV and TSV

CSV and TSV input with a header row becomes an array of objects:

yaml
steps:
  - id: users
    action: data.convert
    with:
      from: csv
      to: yaml
      data: |
        name,role
        Alice,admin
        Bob,viewer

For headerless CSV, provide columns when you want objects:

yaml
steps:
  - id: users
    action: data.convert
    with:
      from: csv
      to: json
      has_header: false
      columns: [name, age]
      data: |
        Alice,30
        Bob,25

Without columns, headerless CSV becomes an array of arrays.

YAML to CSV

Use columns to make CSV column order deterministic:

yaml
steps:
  - id: report
    action: data.convert
    with:
      from: yaml
      to: csv
      columns: [name, age]
      data: |
        - name: Alice
          age: 30
        - name: Bob
          age: 25

Output:

csv
name,age
Alice,30
Bob,25

Combining with jq

Use data.convert for format conversion and data.pick for simple selection:

yaml
steps:
  - id: users
    action: data.convert
    with:
      from: csv
      to: json
      data: |
        name,age
        Alice,30
    output: USERS_JSON

  - id: first_name
    action: data.pick
    with:
      from: json
      select: '.[0].name'
      data: ${USERS_JSON}
      raw: true
    output: FIRST_NAME
    depends: users

Use jq.filter when you need full jq expressions such as filtering, grouping, or reshaping arrays.

Picking from YAML

yaml
steps:
  - id: image
    action: data.pick
    with:
      from: yaml
      select: .spec.containers[0].image
      raw: true
      data:
        spec:
          containers:
            - image: nginx:1.27
    output: IMAGE

Size Guidance

data.convert is intended for small values and step outputs. For large CSV files, use postgres.import, sqlite.import, or the official duckdb@v1 action with DuckDB SQL such as read_csv_auto.

Released under the MIT License.