How to change the delimiter when exporting CSV from Excel?

Reading Time: 4 minutes.

Recently, I needed to find a way to import data from an Excel to a custom-coded system that could import CSV files. However, the data was fairly unsanitized – containing commas, semicolons and other weird characters. I could define the delimiter used in the imported data – however, to do that, I needed to also be able to define it in the export.

What’s a “CSV” -file ?

Stands for “comma-separated values” – A text file that uses a comma to separate values.

Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator (Delimiter) is the source of the name for this file format.

With Excel, it’s not that simple, though. Excel, just like other Microsoft Office applications loves trying its best to respect the regional & localization settings of the machine it’s running on – most often to frustrating results.

However, like with so many other things, you can change the delimiter value used in CSV export by tweaking these settings. And this article describes how!

Note: This guide applies to Windows 10 – see the bottom of the page to find a similar solution for Windows 7!

Background

Another day, another workaround. Let’s delve into the background of the issue a bit deeper:

I needed to wrangle data stored in an .xlsx file into another form, that another application could read. Normally, that’s simple – just change the file type. However, this time I was posed with an issue: the data included both commas (“,”) and semicolons (“;”), both of which are typical delimiters in CSV files. Additionally, I couldn’t wrap the values inside quotes due to limitations in both the export and the import functionality. So I needed to use another character – such as pipe (“|”).

Instead of being able to configure the delimiter in the export (like in any sensible spreadsheet editor, if you ask me!), Excel is just going to use your regional settings and grab the list separator from there. This means that in English, CSV is going to be values limited by commas, like this:

Value1,Value2,Value3,Value4...

But in Finnish, we’ll be using the semicolon – like so:

Value1;Value2;Value3;Value4...

Simply changing the regional settings isn’t a solution this time, though – the data I had been supplied had both colons and semicolons in cell values. The data would be incorrectly split and parsed due to that.

However, luckily we can override the delimiter used for any regional settings!

Solution

I found a couple of examples on how to do it in Windows 7 – and obviously, that’ll help you eventually find your way in Windows 10 as well. But always useful to also document the exact steps :)

Here are the steps in writing – see some useful screenshots further below!

How to export a CSV with custom delimiter using Microsoft Excel:

  1. Make sure Excel is closed
  2. Open Control Panel
    1. This can be done by hitting win+r and writing “Control Panel” in the Run-window
  3. Select “Region
  4. Click the “Additional Settings” -button
  5. Find the “List separator” and change it to your preferred delimiter such as a pipe (“|”).
  6. Click OK -> OK -> exit Control Panel
  7. Open the Excel file you want to export to a pipe delimited file
  8. Select File, Save As
  9. Change the ‘Save as type’ to ‘CSV (Comma delimited)(*.csv)’
  10. Change the name and file extension if you want, by default stays as csv even though a different delimiter
  11. Click Save -> OK -> Yes

And the same with pictures!

Fire up your Control Panel, and open “Region”.

Select “Additional settings” – and then you have access to “List separator”!


While the dropdown might have some prepopulated values, you can actually just safely ignore them and input whatever delimiter you need to use to the textfield directly.

Even something nonsensical and borderline rude like this should work :)

Note, that there’s at least one, undocumented limitation here: you can’t use the same character as both decimal and list separator! This means that if you’re using regional settings like Finnish, where comma is considered to be decimal separator instead of a full stop or “dot”, you can’t use it as a list delimiter… Before you change the decimal separator to something else, that is :)

With the selection done, just hit “OK” a couple of times and head back to Excel! You should be able to save your file as CSV or use the Export-function – and you should be good this time!

References

Big kudos to Barry Stevens documenting the solution and Sami Laiho (or, like he’s better known, “the dude with the Järjestelmänvalvoja shirt”) for noticing you can’t use the same character as both decimal and list separator 😬

mm
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments