Merged and multi-row headers
The column names are spread over two or more rows, often with merged cells, so no single row names every column.
What it looks like
Before
| column A | column B | column C |
|---|---|---|
| · | sales 2024 | · |
| region | q1 | q2 |
| North | 120 | 95 |
After
| column A | column B | column C |
|---|---|---|
| region | sales_2024_q1 | sales_2024_q2 |
| North | 120 | 95 |
How it happens
- The sheet was laid out as a report for people to read, with a banner heading over groups of columns.
- Cells were merged for appearance, which leaves every cell but the first one empty.
- A title, a date, or a logo row sits above the real header.
What it breaks
- Software takes the first row as the header, so columns are named after a banner or left unnamed.
- The second header row is read as data, which turns numeric columns into text.
- Columns under a merged heading lose it, and two columns both called q1 cannot be told apart.
How to spot it
- Look at the first few rows for merged cells, empty header cells, and repeated names.
- Check whether the first row of data holds labels instead of values.
- After importing, look for columns with generated names or numbers where names should be.
How to fix it
- Fill each merged heading across the columns it covered.
- Combine the header rows into one name per column, joining the levels in a consistent order.
- Remove title and decoration rows from the table, and keep what they said, such as the reporting period, in a column or in the file's documentation.
- Check that every resulting name is unique.
- Totals and notes rows inside the dataRows that are not records, such as subtotals, grand totals, and footnotes, sit among the rows that are.
- Wide tables that should be longValues of one variable, such as months or years, are spread across the column headers instead of being stored in a column of their own.
- Inconsistent column names across filesFiles that should share one layout name the same column differently, or use the same name for different things.
TermsHeader, Schema, Tidy data, Tabular data