Solution
When the CSV was opened, Excel treated the postcodes as numbers and removed the leading zero. When it was saved, “01001” became “1001”, and the platform rejected the four-digit codes. Only provinces whose codes start with 0 were affected.
What happened?
A CSV is a text file: it does not say whether “01001” is a number or text. When it opens the file, Excel decides the type of each value and, if it looks like a number, converts it. In a number, leading zeros have no value, so they disappear. Microsoft documents this: Excel automatically removes leading zeros, including when it opens a .csv file.
Spanish postcodes have five digits and, under the Order of 23 January 1984, the first two identify the province using the national geographic code. In that coding, published by the INE (Spain’s National Statistics Institute), codes 01 to 09 are Álava, Albacete, Alicante, Almería, Ávila, Badajoz, the Balearic Islands, Barcelona and Burgos. This is what happened:
The website exported a correct CSV, with codes such as 01001 or 08001.
When it was opened with a double-click, Excel converted that column into numbers: 01001 became 1001, and 08001, 8001.
The volunteer saved the file as CSV. Excel wrote the values as it held them, without the zero.
The courier platform expected five digits and rejected the four-digit codes. Those for Madrid (28…), Seville (41…) or Valencia (46…) do not start with zero and did not change.
That is why the problem seemed to depend on the province: it only affected the nine whose codes start with 0.
How could it be fixed and prevented?
To fix it , the CSV needed to be exported again from the website instead of trying to repair the modified one. If anything needed correcting, it could be done in a text editor or by importing the file into Excel with Data > From Text/CSV , opening the Power Query editor and changing the postcode column type to Text under Data Type before loading it.
To stop it from happening again , several measures helped:
Do not double-click CSV files that contain codes. It is better to import them and specify that postcode, phone number or ID number columns are text.
Turn off automatic conversion in Excel. In versions that include it, such as Microsoft 365 and Excel 2024, go to File > Options > Data > Automatic Data Conversion and clear “Remove leading zeros from numerical text and convert to a number”.
Validate the data before sending it, for example by checking that every postcode has five digits.
Treat identifiers as text when they are not used for calculations, even if they only contain digits.
‹
Case 14/21
›
A project by Eniun