Disclosure: This is the English edition of an explainer I originally made in Japanese. It was translated with AI assistance, then reviewed and edited. Every example below uses dummy data.
Open a CSV the usual way — double-click — and Excel can automatically convert some values as it opens the file. Depending on your regional settings, Excel can interpret product codes as dates. In this example:
- A product code like
1-2comes in as January 2. -
3-4becomes March 4.
(The codes are dummy data; the product names — bolt set, adapter, cable — are made up.)
Nothing in the file was broken. The damage happens at import: Excel sees a run of digits and symbols and decides it must be a date. And once a cell has been converted, changing its format to Text does not recover the original code. Reimport the original CSV with the code column set to Text — the only intact copy is the CSV file itself, so don't save over it.
This post focuses on stopping that conversion when you import a CSV into Excel.
Why it happens
A CSV field carries no type information. The file is plain text, and it doesn't say whether 1-2 is a date or a label.
When Excel opens a CSV directly, it guesses the type of each cell. A pattern like digits, a hyphen, and more digits looks like a date, so Excel converts it — and a code that was never a date is now one. This is the same automatic type detection discussed in the earlier post about leading zeros and scientific notation: Excel decides the type for you when it opens the file.
The real problem is a category error: product codes like 1-2, 3-4, and 11-12 are identifiers, not dates. They only look like dates; they behave like text. The import step doesn't know that — unless you tell it.
The fix: control the type at import
Don't open the CSV by double-clicking. Import it instead:
- On the Data tab, choose From Text/CSV and select your file.
- In the preview, click Transform Data to open the Power Query Editor. Select the code column and set its data type to Text. If the code column was automatically converted to a date, choose Replace current when prompted. Adding a Text conversion after the date conversion would give you the date as text, rather than recover the original code.
- Click Close & Load. The codes come in exactly as written in the file:
1-2,3-4,11-12.
That's the whole fix — the same one as in the leading-zero post earlier in this series. The codes were never the problem; the uncontrolled type conversion was. If a column holds codes, import it as Text. Check the result before saving: overwriting the original CSV would replace its codes with the converted values.
Watch it happen
I made a short video of this case — showing 1-2 turning into a date, and the same import fix. The narration and on-screen text are in Japanese:
https://www.youtube.com/shorts/puSFF-PD7qY
Next in this series: why a CSV opens as garbled text, and the encoding fix.
This post is part of a small series checking what spreadsheets do to files you receive from other people — and how to open them without losing what's inside.
Top comments (0)