How to clean and convert CSV and Excel files
Fix delimiters and encoding, keep leading zeros from disappearing, and handle dates, number formats and duplicate rows.
Published: 26 November 2026Updated: 26 November 20263 min readGuides are written in English.
Exports from other systems fail in ways that look like corruption but are almost always one of five causes: the wrong delimiter, the wrong character encoding, cells silently retyped, duplicated rows, or numbers carrying thousand separators. Each has a check you can run in under a minute.
Delimiters
CSV is not a single format. A comma-separated file from a US system, a semicolon-separated file from a European Excel install, and a tab-separated export from a database all claim to be "CSV". If every row arrives as a single column, the delimiter was wrong. CSV Transform detects the delimiter from the first lines and reports which one it used; if detection is fooled by a comma inside a quoted field, set the delimiter explicitly.
Character encoding
Text stored as UTF-8 and read as Windows-1252 produces the familiar `é` and `’`. The bytes are not wrong; the interpretation is. Open the file with UTF-8 selected, and if it still fails, the source really was Windows-1252 and needs converting rather than reinterpreting. A byte-order mark at the start of the file is invisible in most editors and appears as a stray character in the first cell of the first row.
The leading-zero trap, measured
This is the most expensive silent error in spreadsheet work. A CSV file stores `00123` as five characters. When that file is parsed into a workbook, the parser sees a number and stores the number 123. The information is gone — the workbook cannot recover the zeros, because they were never stored.
| Field in the CSV | Value after conversion to XLSX |
|---|---|
| order_id = "00123" | 123 |
| postcode = "02139" | 2139 |
Both conversions were observed in the CSV-to-workbook path used by the converters here, and both are standard spreadsheet behaviour rather than a bug in one tool. They affect order numbers, employee IDs, account numbers, phone numbers, postcodes, product codes and anything else with a meaningful leading zero.
Three ways to protect the data: keep the column as text in the workbook (format the column as Text before importing, or prefix each value with an apostrophe, which spreadsheet apps hide), keep the original CSV as the system of record, or convert only the numeric columns and leave identifiers alone.
Dates and numbers
- `03/04/2026` is 3 April in the UK and 4 March in the US. Convert to ISO 8601 (`2026-04-03`) before analysis so the meaning is explicit.
- `1,240.50` and `1.240,50` are the same number in different locales. A single import with the wrong locale produces values off by a factor of a thousand.
- Currency symbols and spaces inside numbers prevent numeric sorting and summation.
- Accounting exports often show negatives as `(1,240.50)`, which is text to a spreadsheet.
Cleaning steps that catch most problems
- Trim whitespace — trailing spaces break matching and de-duplication.
- Drop empty rows, which otherwise become blank records downstream.
- De-duplicate on the whole row. In a test file with a repeated order line, four data rows became three.
- Sort by a numeric column with numeric sorting enabled, so `10` does not sort before `9`.
- Select and reorder columns to match the destination system's expected order.
- Transpose when a report arrives as columns instead of rows.
Formula injection
A cell beginning with `=`, `+`, `-` or `@` is a formula when opened in a spreadsheet application. If the content came from a user — a contact form, a review, a name field — it can execute. This is a documented class of attack (see the OWASP CSV Injection reference). Toolkitool's CSV writer neutralises such cells with a leading apostrophe so the text survives and the formula does not run; if you build your own export path, do the same.
Reference: OWASP, CSV Injection — the attack class behind that guard.
File sizes that look wrong
A three-row workbook is about 16 KB and a three-sheet workbook with 501 rows per sheet is about 270 KB. The small file is not empty — `.xlsx` is a compressed archive of XML parts with fixed overhead. Judge a conversion by its rows, not its size.
Related: Excel CSV Converter, Excel Data Cleaner, CSV Transform, business cards to a contact list.