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
.gzare transparently decompressed.
Output:
- By default, output is written to standard output.
- Use
--outfile/-oto 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:
-
Transpose a TSV file
tva transpose data.tsv -
Transpose and save to a file
tva transpose data.tsv -o output.tsv -
Transpose with custom delimiter
tva transpose --delimiter "," data.csv