All guides

The Google Analytics CSV: comment lines above the heading, a second table underneath, and numbers with commas

A report downloaded from Google Analytics as CSV is built for a person, not a program: several lines beginning with # give the report name and date range, then the headings and the rows, then a blank line and a second, smaller table with a different set of columns — a per-day series under a per-page one. Numbers carry thousands separators, percentages carry their sign, and dates are written as 20240131. The editor here cuts it down to the one table you want; the rest of the tools take it from there.

What the download looks like

The first lines each begin with a # and hold the report name, the date range and a rule of dashes; a reader that expects headings on line one gets one column called # and everything under it. The main table follows. Below it, after a blank line, comes a second table — typically the day-by-day series for the same metric — with its own headings, so the file has two widths and any reader taking the first heading row pads or cuts the second table to fit.

The values are formatted as the screen shows them: 12,345 with a separator, 45.67% with its sign, 00:02:31 for a duration, and dates as YYYYMMDD with no separators. Every one of them is text to a careful reader and a guess to a careless one.

Make it one table

Open the file in the editor here and untick "First row is headings" first: otherwise the first # line is taken as the headings and cannot be deleted, and the grid shows only its one column. With it unticked every line is a row — delete the comment lines above the heading, the blank line and the second table below the data, leave the toggle off, and download. The remaining rows are exactly the export’s, byte for byte, with the one table’s headings first. The health check then reports a single width and lists nothing ragged.

If the second table is the one you wanted, delete the first instead; the editor does not care which rows go.

Then the numbers and dates

The separators and signs stay in the values here, which is the safe default: nothing is turned into a number until you say so. The SQL console removes the separators and converts inside a sum, turns 20240131 into 2024-01-31 with one expression, and groups or totals the rows as the report did not. The download from there is a plain CSV or an Excel workbook of text cells.

The compare tool takes two downloads of the same report for different ranges and lists what changed, page by page.

Questions

Why does the file open with a column called #?
Because the first lines are comments beginning with #, and the reader took the first of them as the heading. In the editor here, untick First row is headings, delete those lines, and download; the real headings are then first.
What is the second table at the bottom?
A day-by-day series for the same report, with its own headings. It is why the file has two widths; keep the table you want and delete the other.
Why are the numbers text with commas in them?
The export writes them as the screen shows them. They stay text here so nothing is misread; the SQL console strips the separators when you total them.
How do I turn 20240131 into a real date?
In the SQL console, one expression slices the year, month and day out and writes 2024-01-31. The original value is left as it was in the file.
Can I compare two downloads of the same report?
Yes. Clean each to one table, then the compare tool lists the rows added, removed and changed between them, cell by cell.
Is my export uploaded anywhere?
No. Cutting the export down to one table is done in the editor inside this page. Your site’s figures stay on your machine; the Network tab in your developer tools shows this site’s own code arriving, never your export leaving.