datamash -t, transpose < data.csv

Category: Data Science & Analysis

datamash -t, transpose < data.csv

Transpose rows and columns of a CSV file

The transpose line-operation swaps rows and columns, turning the first row into the first column and so on. This is the same transformation as a spreadsheet paste-special transpose feature. It is a standalone operation, so no statistic or field number is needed. Transposed files are sometimes required by tools that expect one observation per column.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.