Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

transpose

Transposes a tab-separated values (TSV) table by swapping rows and columns.

Behavior:

  • Reads a single TSV input as a whole table and performs a matrix transpose.
  • Uses the number of fields in the first line as the expected width.
  • All subsequent lines must have the same number of fields.
  • On mismatch, an error is printed and the command exits with non-zero status.
  • This command only operates in strict mode; non-rectangular tables are rejected.

Input:

  • Reads from files or standard input.
  • Files ending in .gz are transparently decompressed.

Output:

  • By default, output is written to standard output.
  • Use --outfile / -o to write to a file instead.
  • For an MxN matrix (M lines, N fields), writes an NxM matrix.
  • If the input is empty, no output is produced.

Examples:

  1. Transpose a TSV file tva transpose data.tsv

  2. Transpose and save to a file tva transpose data.tsv -o output.tsv

  3. Transpose with custom delimiter tva transpose --delimiter "," data.csv