What a CSV file is, and why Excel keeps breaking it
A CSV file is plain text where each line is a record and the fields inside it are separated by a delimiter, usually a comma. It is the most portable way to move a table between programs, which is why it shows up in bank exports, CRM dumps and analytics downloads. The format is simple. Most of the problems come from what applications do with it after it is opened.
The shape of a CSV file
The first line is often a header row with column names, and every line after it is one row. A value that contains the delimiter, a line break or a double quote is wrapped in double quotes, and a quote inside a quoted value is doubled. The format is described in RFC 4180, although many real files bend it.
A tiny example with three columns:
id,name,city1,"Novak, Jan",Brno2,Eva,Praha
Why Excel breaks it
Excel does not read the file the way a parser does. It opens it with your computer's regional settings, and three things commonly go wrong:
- The delimiter. Locales that use a decimal comma expect semicolons, so a comma-separated file lands in one column.
- Leading zeros. A postcode like
01234becomes1234, because Excel reads the value as a number. - Accents. Without a UTF-8 byte-order mark, names such as
Ondřejcan come out garbled.
The usual fix is to import the file with explicit settings and mark the ID column as text, instead of double-clicking it.
Converting without a spreadsheet
If the next step is code, a CSV is often easier to handle as JSON. The CSV to JSON converter reads the header row and produces one object per line, and it runs entirely in your browser. Going the other way, the JSON to CSV converter flattens an array of objects into rows, which is the format most import screens expect.
Practical checks before you import
- Open the file in a plain text editor first. An odd number of quotes on one line means the file is malformed.
- Check the delimiter in the first line. A header such as
id;name;cityis semicolon-separated. - Keep IDs and postcodes as text in the import settings, not as numbers.
- Keep a copy of the original. Excel rewrites dates and numbers the moment you save over it.
Creator of TextArray — building free, privacy-first tools that run entirely in your browser.