
Someone sends you a CSV export and asks a simple question: how many orders came from each region last month? The file opens, the numbers look plausible, and an hour later you find that half the dates were read as text and a column of product codes lost its leading zeros. CSV is the most common way data moves between systems, and it is also the easiest format to misread.
A few minutes of checking before you start saves most of that hour.
What a CSV file is
A CSV file is plain text. Each line is a row, and a separator splits each row into columns. That’s all. There is no record of which column holds dates, which holds numbers, or what character set the text uses. Every program that opens the file has to guess, and different programs guess differently.
That is why the same file can look fine in one tool and broken in another.
Five things to check first
The separator
Comma is the default, but many exports use semicolons, especially from systems set up for European number formats, where the comma is the decimal mark. Tabs and pipes turn up too. If every row lands in a single column, the program guessed the wrong separator.
The encoding
Names with accents, currency symbols and non-Latin scripts break when a file saved as UTF-8 is read as something else, or the other way round. Look for garbled characters such as “é” where “é” should be. Most tools let you choose the encoding when you import.
Leading zeros and long numbers
Spreadsheet programs often convert columns that look numeric. Postal codes, phone numbers and product codes lose their leading zeros, and long ID numbers get rounded or shown in scientific notation. Import those columns as text, not as numbers.
Dates
“03/04/2026” is the 3rd of April in most of the world and the 4th of March in the United States. Check a few rows where the day is above 12. If the file mixes formats, sort the column and look at both ends.
Quotes and line breaks inside fields
A comment field that contains a comma or a line break should be wrapped in quotes. If it isn’t, rows split in the wrong place and every column after it shifts. A quick count helps: the number of rows your tool shows should match what the person who exported it expects.
Counting and summing: where SQL helps
Once the file is clean, the actual questions start. How many rows per region? What is the total per month? Which customers appear more than once? You can answer these with filters and pivot tables in a spreadsheet, and for a one-off look that’s often the fastest route.
When the questions repeat, or the file has hundreds of thousands of rows, loading it into a small database and querying it with SQL is more reliable. SQLite works well for this: a single file, no server, and many tools can import a CSV straight into a table. After that, the question from the start of this article is one query:
SELECT region, COUNT(*) AS orders
FROM orders
WHERE order_date >= '2026-10-01' AND order_date < '2026-11-01'
GROUP BY region
ORDER BY orders DESC;
The query is written down, so the next person can see exactly how the number was produced, and you can run it again on next month’s export without redoing any clicks.
Getting comfortable with the queries
Most people who work with exports only need a handful of SQL patterns: filtering with WHERE, grouping with GROUP BY, joining two tables, and spotting duplicates. The quickest way to learn them is to write them against real tables and see whether the result is right.
If you’d like somewhere to practice, The Work Gym has SQL exercises that run in the browser, from simple SELECT statements to joins and window functions, and each answer is checked when you run it. The first unit is free and needs no account.
A short checklist
- Confirm the separator and the encoding before anything else.
- Import ID, code and phone columns as text.
- Check dates on rows where the day is above 12.
- Compare the row count with what the sender expects.
- Write the question as a query once it needs answering more than once.