Pivot a CSV from long to wide (and back)

Choose row identifiers, the column whose values become headers, and how to combine several values that land in one cell. Absent cells are filled the way you choose.

Example data — not saved

Showing synthetic sample data: Pivot survey answers. Open or drop your own file to replace it — files are read in your browser and never uploaded.

Source AUpdating…
Loading…

Arrow keys move; Enter or double-click edits a cell (recorded as a replayable “Cell edits” step). ∅ = missing, · = edge whitespace, ↵ = line break inside a value. Row labels show source:record provenance.

Duplicates and gaps are explicit

The example turns survey answers into one row per respondent and one column per question. Respondent r3 answered Q3 twice. With “Mean” the two answers become 4.5, and the step reports one cell with more than one value. “Keep first” would be reported as a loss.

r3 skipped Q2 entirely, so that cell is absent; r2 answered Q2 with an empty value, which is different. Absent cells are filled as missing, empty text or 0, according to your choice.

Unpivot is the reverse: pick identifier columns and the columns to turn into name/value rows. Pivoting an unpivoted table with “Keep first” reproduces the original exactly, which the test suite checks.

Questions

What if a column has thousands of distinct values?

A preflight limit (500 columns by default) stops the pivot before it builds an unusable table. Filter first or raise the limit deliberately.

Are sums and means exact?

Yes. They use exact decimal arithmetic; means are rounded half-even to the number of places you choose.

How do I group without pivoting?

Use “Group & aggregate” for one row per group with count, sum, min, max, mean, distinct count or concatenation.