transpose

Transposes the table contents so rows become columns and columns become rows.

Signature

> transpose ...rest --header-row --ignore-titles --as-record

Parameters

  • ...rest: the names to give columns once transposed
  • --header-row: treat the first row as column names
  • --ignore-titles: don't transpose the column names into values
  • --as-record: transfer to record if the result is a table and contains only one row

Examples

Transposes the table contents with default column names

> echo [[c1 c2]; [1 2]] | transpose

Transposes the table contents with specified column names

> echo [[c1 c2]; [1 2]] | transpose key val

Transposes the table without column names and specify a new column name

> echo [[c1 c2]; [1 2]] | transpose -i val

Transfer back to record with -d flag

> echo {c1: 1, c2: 2} | transpose | transpose -i -r -d