CSV Transposer
Transpose CSV data instantly - swap rows and columns online. Supports auto-delimiter detection, file upload, drag & drop, and RFC 4180 parsing.
About
Transposing a CSV file means converting its rows into columns and its columns into rows. The element at row i, column j in the source becomes row j, column i in the output. This operation is critical when data orientation does not match the expected input format of statistical software, database import wizards, or visualization pipelines. Feeding a column-oriented dataset into a tool that expects row-oriented records produces silent errors - wrong aggregations, broken joins, corrupted charts. This tool parses CSV strictly per RFC 4180, handles quoted fields with embedded delimiters and newlines, auto-detects the delimiter, and transposes the matrix in-browser with no server upload.
Limitations: jagged rows (unequal column counts) are padded with empty cells. Files over 10 MB are rejected to prevent browser memory exhaustion. Encoding is assumed UTF-8. The parser does not interpret data types - all cells remain strings. For extremely wide CSVs (thousands of columns), the resulting transposed file will have thousands of rows, which is normal but may affect downstream tools with row-count limits.
Formulas
The transpose operation maps every element from its source position to a swapped position in the output matrix.
Where A is the input matrix of dimensions m × n (rows × columns), and B is the transposed output of dimensions n × m. For every row index i ∈ [0, m−1] and column index j ∈ [0, n−1], the value at row i, column j in A is placed at row j, column i in B.
Delimiter auto-detection counts occurrences of each candidate delimiter in the first 5 lines. The candidate with the highest consistent count across all sampled lines is selected. Tie-breaking order: comma → semicolon → tab → pipe.
The CSV parser uses a finite state machine with three states: FIELD_START, UNQUOTED, and QUOTED. Transitions occur on encountering the delimiter character, the quote character, or a newline. This guarantees correct handling of fields that contain the delimiter itself, embedded newlines, or escaped quotes ("" → ").
Reference Data
| Delimiter | Symbol | Common File Extensions | Typical Use Case | Auto-Detected |
|---|---|---|---|---|
| Comma | , | .csv | Standard CSV exports (Excel, Google Sheets) | Yes |
| Semicolon | ; | .csv | European locale CSV (decimal comma conflicts) | Yes |
| Tab | \t | .tsv, .txt | Database dumps, clipboard paste from spreadsheets | Yes |
| Pipe | | | .txt, .dat | Legacy mainframe exports, log files | Yes |
| Custom | User-defined | Any | Non-standard delimited files | No (manual) |
| RFC 4180 Rules | ||||
| Rule 1 | Each record is on a separate line, delimited by a line break (CRLF) | |||
| Rule 2 | The last record may or may not have an ending line break | |||
| Rule 3 | An optional header line may appear as the first line | |||
| Rule 4 | Fields may be enclosed in double quotes | |||
| Rule 5 | Fields containing line breaks, double quotes, or the delimiter must be quoted | |||
| Rule 6 | A double quote inside a quoted field is escaped by preceding it with another double quote | |||
| Transpose Properties | ||||
| Symmetry | Transposing twice returns the original matrix: (AT)T = A | |||
| Dimensions | An m × n matrix becomes n × m | |||
| Cell Count | Total cells preserved: m ⋅ n = n ⋅ m | |||
| Jagged Handling | Short rows padded with empty strings to match the longest row before transposing | |||