Csv separator for excel

Import or export text (.txt or .csv) files

There are two ways to import data from a text file with Excel: you can open it in Excel, or you can import it as an external data range. To export data from Excel to a text file, use the Save As command and change the file type from the drop-down menu.

There are two commonly used text file formats:

  • Delimited text files (.txt), in which the TAB character (ASCII character code 009) typically separates each field of text.

  • Comma separated values text files (.csv), in which the comma character (,) typically separates each field of text.

You can change the separator character that is used in both delimited and .csv text files. This may be necessary to make sure that the import or export operation works the way that you want it to.

Note: You can import or export up to 1,048,576 rows and 16,384 columns.

Import a text file by opening it in Excel

You can open a text file that you created in another program as an Excel workbook by using the Open command. Opening a text file in Excel does not change the format of the file — you can see this in the Excel title bar, where the name of the file retains the text file name extension (for example, .txt or .csv).

  1. Go to File > Open and browse to the location that contains the text file.

  2. Select Text Files in the file type dropdown list in the Open dialog box.

  3. Locate and double-click the text file that you want to open.

    • If the file is a text file (.txt), Excel starts the Import Text Wizard. When you are done with the steps, click Finish to complete the import operation. See Text Import Wizard for more information about delimiters and advanced options.

    • If the file is a .csv file, Excel automatically opens the text file and displays the data in a new workbook.

      Note: When Excel opens a .csv file, it uses the current default data format settings to interpret how to import each column of data. If you want more flexibility in converting columns to different data formats, you can use the Import Text Wizard. For example, the format of a data column in the .csv file may be MDY, but Excel’s default data format is YMD, or you want to convert a column of numbers that contains leading zeros to text so you can preserve the leading zeros. To force Excel to run the Import Text Wizard, you can change the file name extension from .csv to .txt before you open it, or you can import a text file by connecting to it (for more information, see the following section).

Import a text file by connecting to it (Power Query)

You can import data from a text file into an existing worksheet.

  1. On the Data tab, in the Get & Transform Data group, click From Text/CSV.

  2. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

  3. In the preview dialog box, you have several options:

    • Select Load if you want to load the data directly to a new worksheet.

    • Alternatively, select Load to if you want to load the data to a table, PivotTable/PivotChart, an existing/new Excel worksheet, or simply create a connection. You also have the choice of adding your data to the Data Model.

    • Select Transform Data if you want to load the data to Power Query, and edit it before bringing it to Excel.

If Excel doesn’t convert a particular column of data to the format that you want, then you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File > Save As.

  2. Click Browse.

  3. In the Save As dialog box, under Save as type box, choose the text file format for the worksheet; for example, click Text (Tab delimited) or CSV (Comma delimited).

    Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

    You may also see an alert below the ribbon that some features might be lost if you save the workbook in a CSV format.

For more information about saving files in other formats, see Save a workbook in another file format.

Import a text file by connecting to it

You can import data from a text file into an existing worksheet.

  1. Click the cell where you want to put the data from the text file.

  2. On the Data tab, in the Get External Data group, click From Text.

  3. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

    Follow the instructions in the Text Import Wizard. Click Help button image on any page of the Text Import Wizard for more information about using the wizard. When you are done with the steps in the wizard, click Finish to complete the import operation.

  4. In the Import Data dialog box, do the following:

    1. Under Where do you want to put the data?, do one of the following:

      • To return the data to the location that you selected, click Existing worksheet.

      • To return the data to the upper-left corner of a new worksheet, click New worksheet.

    2. Optionally, click Properties to set refresh, formatting, and layout options for the imported data.

    3. Click OK.

      Excel puts the external data range in the location that you specify.

If Excel does not convert a column of data to the format that you want, you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File > Save As.

  2. The Save As dialog box appears.

  3. In the Save as type box, choose the text file format for the worksheet.

    • For example, click Text (Tab delimited) or CSV (Comma delimited).

    • Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

  6. A second dialog box appears, reminding you that your worksheet may contain features that are not supported by text file formats. If you are interested only in saving the worksheet data into the new text file, click Yes. If you are unsure and would like to know more about which Excel features are not supported by text file formats, click Help for more information.

For more information about saving files in other formats, see Save a workbook in another file format.

The way you change the delimiter when importing is different depending on how you import the text.

  • If you use Get & Transform Data > From Text/CSV, after you choose the text file and click Import, choose a character to use from the list under Delimiter. You can see the effect of your new choice immediately in the data preview, so you can be sure you make the choice you want before you proceed.

  • If you use the Text Import Wizard to import a text file, you can change the delimiter that is used for the import operation in Step 2 of the Text Import Wizard. In this step, you can also change the way that consecutive delimiters, such as consecutive quotation marks, are handled.

    See Text Import Wizard for more information about delimiters and advanced options.

If you want to use a semi-colon as the default list separator when you Save As .csv, but need to limit the change to Excel, consider changing the default decimal separator to a comma — this forces Excel to use a semi-colon for the list separator. Obviously, this will also change the way decimal numbers are displayed, so also consider changing the Thousands separator to limit any confusion.

  1. Clear Excel Options > Advanced > Editing options > Use system separators.

  2. Set Decimal separator to , (a comma).

  3. Set Thousands separator to . (a period).

When you save a workbook as a .csv file, the default list separator (delimiter) is a comma. You can change this to another separator character using Windows Region settings. 

Caution: Changing the Windows setting will cause a global change on your computer, affecting all applications. To only change the delimiter for Excel, see Change the default list separator for saving files as text (.csv) in Excel.

  1. In Microsoft Windows 10, right-click the Start button, and then click Settings.

  2. Click Time & Language, and then click Region in the left panel.

  3. In the main panel, under Regional settings, click Additional date, time, and regional settings.

  4. Under Region, click Change date, time, or number formats.

  5. In the Region dialog, on the Format tab, click Additional settings.

  6. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.

  7. Click OK twice.

  1. In Microsoft Windows, click the Start button, and then click Control Panel.

  2. Under Clock, Language, and Region, click Change date, time, or number formats.

  3. In the Region dialog, on the Format tab, click Additional settings.

  4. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.

  5. Click OK twice.

Note:  After you change the list separator character for your computer, all programs use the new character as a list separator. You can change the character back to the default character by following the same procedure.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See Also

Import data from external data sources (Power Query)

Need more help?

For Dutch I had a problem that Excel 2008 on Windows 7 did not adhere to RFC4180:

«Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.»

A comma-separated file correctly had fields with a comma (Dutch decimal separator) enclosed in double quotes. In the Dutch locale the decimal separator is , and list separator is ; so Excel could not read a file with , used for both (not even after explicitly changing the list separator to , in Control Panel).

The input looks like:

"06-07-2017 17:03:18","********",0:01:04,Uitgaand,"0,1879","0,2273","0,0395",21

The solution was given by @user280725:

Use Notepad to insert as a first line:

sep=,

(This means the Note of user @zakinster in his solution no longer needs to apply.)


Interesting: with the csv file still loaded, if you now set the locale to US English in Control Panel and save the file, it will have been converted to US English format (comma as list separator and dot as decimal separator).

How is a CSV file built in general? With commas or semicolons?
Any advice on which one to use?

Lance Roberts's user avatar

Lance Roberts

22.2k32 gold badges112 silver badges129 bronze badges

asked Apr 13, 2012 at 12:39

membersound's user avatar

membersoundmembersound

79.5k182 gold badges566 silver badges1081 bronze badges

3

In Windows it is dependent on the «Regional and Language Options» customize screen where you find a List separator. This is the char Windows applications expect to be the CSV separator.

Of course this only has effect in Windows applications, for example Excel will not automatically split data into columns if the file is not using the above mentioned separator. All applications that use Windows regional settings will have this behavior.

If you are writing a program for Windows that will require importing the CSV in other applications and you know that the list separator set for your target machines is ,, then go for it, otherwise I prefer ; since it causes less problems with decimal points, digit grouping and does not appear in much text.

Marcos Dimitrio's user avatar

answered Apr 13, 2012 at 12:49

Sibster's user avatar

5

CSV is a standard format, outlined in RFC 4180 (in 2005), so there IS no lack of a standard. https://www.ietf.org/rfc/rfc4180.txt

And even before that, the C in CSV has always stood for Comma, not for semiColon :(

It’s a pity Microsoft keeps ignoring that and is still sticking to the monstrosity they turned it into decades ago (yes, I admit, that was before the RFC was created).

  • One record per line, unless a newline occurs within quoted text (see below).
  • COMMA as column separator. Never a semicolon.
  • PERIOD as decimal point in numbers. Never a comma.
  • Text containing commas, periods and/or newlines enclosed in «double quotation marks».
  • Only if text is enclosed in double quotation marks, such quotations marks in the text escaped by doubling. These examples represent the same three fields:

    1,»this text contains «»quotation marks»»»,3

    1,this text contains «quotation marks»,3

The standard does not cover date and time values, personally I try to stick to ISO 8601 format to avoid day/month/year — month/day/year confusion.

answered Jun 18, 2015 at 14:45

Luc VdV's user avatar

Luc VdVLuc VdV

1,0189 silver badges13 bronze badges

11

I’d say stick to comma as it’s widely recognized and understood. Be sure to quote your values and escape your quotes though.

ID,NAME,AGE
"23434","Norris, Chuck","24"
"34343","Bond, James ""master""","57"

answered Apr 13, 2012 at 12:41

adarshr's user avatar

adarshradarshr

60.9k23 gold badges137 silver badges167 bronze badges

4

Also relevant, but specially to excel, look at this answer and this other one that suggests, inserting a line at the beginning of the CSV with

"sep=,"

To inform excel which separator to expect

answered Nov 21, 2016 at 12:23

Rafareino's user avatar

RafareinoRafareino

2,4251 gold badge19 silver badges26 bronze badges

1

1.> Change File format to .CSV (semicolon delimited)

To achieve the desired result we need to temporary change the delimiter setting in the Excel Options:

Move to File -> Options -> Advanced -> Editing Section

Uncheck the “Use system separators” setting and put a comma in the “Decimal Separator” field.

Now save the file in the .CSV format and it will be saved in the semicolon delimited format.

Anil_M's user avatar

Anil_M

10.7k6 gold badges45 silver badges72 bronze badges

answered Aug 9, 2016 at 13:47

hugo bourret-desmarais's user avatar

CSV is a Comma Seperated File. Generally the delimiter is a comma, but I have seen many other characters used as delimiters. They are just not as frequently used.

As for advising you on what to use, we need to know your application. Is the file specific to your application/program, or does this need to work with other programs?

answered Apr 13, 2012 at 12:40

Youssef G.'s user avatar

Youssef G.Youssef G.

6074 silver badges10 bronze badges

3

To change comma to semicolon as the default Excel separator for CSV — go to Region -> Additional Settings -> Numbers tab -> List separator
and type ; instead of the default ,

answered Feb 15, 2016 at 7:50

Michael's user avatar

1

Well to just to have some saying about semicolon. In lot of country, comma is what use for decimal not period. Mostly EU colonies, which consist of half of the world, another half follow UK standard (how the hell UK so big O_O) so in turn make using comma for database that include number create much of the headache because Excel refuse to recognize it as delimiter.

Like wise in my country, Viet Nam, follow France’s standard, our partner HongKong use UK standard so comma make CSV unusable, and we use t or ; instead for international use, but it still not «standard» per the document of CSV.

answered Nov 16, 2016 at 8:17

Tran Vu Dang Khoa's user avatar

best way will be to save it in a text file with csv extension:

Sub ExportToCSV()
Dim i, j As Integer
Dim Name  As String

Dim pathfile As String

Dim fs As Object
    Dim stream As Object

    Set fs = CreateObject("Scripting.FileSystemObject")
On Error GoTo fileexists

i = 15
Name = Format(Now(), "ddmmyyHHmmss")
pathfile = "D:1" & Name & ".csv"

Set stream = fs.CreateTextFile(pathfile, False, True)

fileexists:

If Err.Number = 58 Then
    MsgBox "File already Exists"
    'Your code here
    Return
End If
On Error GoTo 0

j = 1
Do Until IsEmpty(ThisWorkbook.ActiveSheet.Cells(i, 1).Value)

    stream.WriteLine (ThisWorkbook.Worksheets(1).Cells(i, 1).Value & ";" & Replace(ThisWorkbook.Worksheets(1).Cells(i, 6).Value, ".", ","))

    j = j + 1
    i = i + 1
Loop


stream.Close

End Sub

hering's user avatar

hering

1,9464 gold badges28 silver badges43 bronze badges

answered Jul 31, 2017 at 6:28

AzizD's user avatar

AzizDAzizD

10310 bronze badges

Although CSV stands for comma-separated values, it has become a common file type to define simple text files including delimiter-separated data. Thus, a CSV file can use a semicolon or tab character as a delimiter as well. In this guide, we’re going to show you how to change CSV delimiter in Excel.

Changing the delimiter in Excel Options

The first approach in our article is about changing how Excel evaluates CSV files including saving. You can make Excel using semicolon (;) as the delimiter.

  1. Open Advanced Options by following File > Options > Advanced.
  2. In the Editing options section, find Use system operators
  3. Uncheck it to override the system settings.
  4. Set Decimal separator to comma (,) and Thousands separator to period (.).
  5. Clicking OK ensures that Excel uses semicolon (;) as the delimiter.

This setting allows Excel to save CSV files with semicolons (;).

If you are using a computer with European version, your settings may already be like above. You can change the operators to convert the delimiter from a semicolon to a comma.

Changing the CSV delimiter when importing files

Excel also allows you to change the delimiter while opening files. This is a more convenient way if you do not want to alter Excel’s entire behavior. Because Excel’s data import features have been updated vastly beginning with 2016, we divided this section into two parts.

Power Query — Excel 2016 and newer

Disclaimer: Power Query has been part of Excel 2010 and Excel 2013 as well. However, Microsoft released it as an add-in. Excel 2016 has the Power Query features by default. You can learn more about Power Query at Power Query 101.

Power Query allows you to choose the delimiter when creating a connection. You can find the option in the Preview dialog. You can create the connection by using From Text/CSV command in Data > Get & Transform Data.

Selecting the file opens the Preview window. Probably, the Power Query guessed the delimiter correctly. However, you can change CSV delimiter easily at a dropdown option.

How to change CSV delimiter in Excel

Use Load or Transform Data buttons to load the data directly into your workbook or modify it in the Power Query window respectively.

Excel 2013 or older

If you are using Excel 2013 or a previous version without the Power Query add-in, you can use Text Import Wizard which shares a similar user interface with Text to Columns wizard.

  1. Click Data > Get External Data > From Text to select a file and open the Text Import Wizard.
  2. In the first step of the wizard, make sure to select Delimited
  3. Click Next button to continue.
  4. Select one or more delimiters that fits your data. You can see if the data is separated correctly in the Data preview section.
    How to change CSV delimiter in Excel 05 - Excel 2013
  5. You can modify data types for columns at the next step. Click Next to continue the third step or click the Finish button to populate the separated data in your worksheet.

This post was most recently updated on March 13th, 2023.

6 min read.

This article will explain how you can change the Excel list delimiter for your CSV (or other) file exports. Because it isn’t always a comma. And setting the delimiter won’t escape or strip the same characters in the values, so it’ll mess up your data quite easily.

Recently, I needed to find a way to import data from an old Excel file to a custom-coded system that could import CSV files. However, the data was fairly non-sanitized – containing commas, semicolons, and other weird characters. I could define the delimiter used in the imported data – however, that would be useless if I wasn’t also able to define it in the export.

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.

Which just means you can change the delimiter value used in CSV export by tweaking these settings. This way, you can change the commas to semicolons, or save the CSV with any other delimiter.

And this article describes how!

Background

If you’re still here, let’s delve into the background of the issue a bit deeper.

I needed to wrangle data stored in a .xlsx file into another form, that another application could read. This file format happened to be CSV. Which brought me into the beautiful world of CSV delimiter configuration in Windows.

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.

Normally, that’s simple – just “save as” with a different file format. 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. Nice and automatic – probably someone thought this to be user friendly, but instead it makes edge cases a pain.

This means that in English, CSV is going to be values limited by commas, like this:

Value1,Value2,Value3,Value4...

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

Value1;Value2;Value3;Value4...

And I could imagine there are plenty of other locales where you might need to tell the values apart with a semicolon instead of a comma. Or you might even need something totally different!

But simply changing my region to something else isn’t a solution this time. 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, we can luckily override the delimiter to be almost anything – and it’s all done through the regional settings. Read on to see for yourself!

Solution

So, I started googling. And naturally, I found a couple of examples on how to save a csv file with a different delimiter in Windows 7… Obviously, that’ll help you eventually find your way in Windows 10 or Windows 11 as well, even though the user interfaces are a bit different. But I thought it’s always useful to also document the exact steps!

The guide below should be accurate for Windows 10 and 11, and be “close enough” for Windows 7. :)

Here are the steps for saving a csv in Excel with a different delimiter, in writing – and see some useful screenshots further below!

Time needed: 10 minutes.

How to export a CSV with a custom delimiter in Excel?

  1. Make sure Microsoft Excel is closed before trying to change the CSV delimiter

    Making sure Excel is closed is required to make sure it picks up your changes.

  2. Open Control Panel

    Opening the Control Panel can be done by hitting win+r and writing “Control Panel” in the Run window.

    Or by searching for “Control Panel” in your start menu. Whichever suits you.

  3. Next, you need to access Regional Settings

    Now you’ll need to navigate to Regional Settings.

    This is where you can find it:

    It’s available either under “Region” or “Clock and Region” -> “Region”.

  4. Click the “Additional settings” -button

    Hit that “Additional settings…” -button now! This will pop up quite a few additional options – in hindsight, not that surprising, but it’s always nice when a button does what you expect it to do.

    Accessing localization settings in Control Panel

  5. Find the “List separator” and change it to your preferred delimiter such as a pipe (“|”).

    You’ll need to edit the “List separator” now.

    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 text field directly.

    How to change the delimiter character for your locale in Control Panel

    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 a comma is considered to be a 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 :)

    This also doesn’t come without some side effects: the same list separator is used, for example, as the separator for passing parameters to an Excel function, as Faz notes in the comments section below.

  6. Click OK -> OK -> exit Control Panel, after which you can proceed to actually export the file!

    With the selection done, just hit “OK” a couple of times and head back to Excel!

    Now we can retry saving the file!

  7. Open the Excel file

    Open the file you want to export to a CSV with a custom delimiter (in my example, to a “pipe-delimited file”).

  8. Select File -> Save As

    Time to save the file! Hit File > “Save as”. This should pop up the classic saving dialog – which in Excel comes with some useful options.

  9. Change the ‘Save as type’ to ‘CSV (Comma delimited)(*.csv)

    Changing to “CSV (Comma delimited)” is admittedly a bit misleading at this point, but we’ll just have to live with that. It will in fact respect your selected delimiter despite the name.

  10. Change the name and file extension if need be

    You can modify the extension and the file name, but by default, it stays as csv even if you’re using a different delimiter.

  11. Click Save -> OK -> Yes

    After hitting a couple of extra affirmative buttons, you should be good!

So now you know how to save (or export, if you prefer that term) a CSV file with a custom delimiter (anything different than a comma or semicolon, depending on your machine configuration) in Microsoft Office Excel on Windows. If you run into any questions, drop them in the comments-section below!


As an interesting side note, you can use completely nonsensical characters as delimiters! Take the picture below as an example – I actually needed this delimiter for a work project once. A project, that’s probably still running in production…

Using horribly weird characters as list delimiters is possible - but probably not advisable.
Using horribly weird characters as list delimiters is possible – but probably not advisable.

What is the default delimiter for a CSV?

If you search for this online, you’ll get the easy answer – a comma. It’s “comma-separated values” after all, right?

Well, as usual, the easy answer is wrong. You can even find it on support.microsoft.com. But it’s still the wrong answer.

The default delimiter is defined by your Windows locale. It’s usually either a comma or a semi-colon, but it’s not necessarily one of those. It can be something different, too. Just so you know.

Why are CSV files so confusing and non-standard?

Because Microsoft wants to implement localization everywhere but doesn’t actually care about people using any other locales than EN-US. 😅


References

Big kudos to Barry Stevens for his blog post on the topic! And also to Sami Laiho, for noticing you can’t use the same character as both decimal and list separator 😬..

  • Author
  • Recent Posts

mm

Antti Koskela is a proud digital native nomadic millennial full stack developer (is that enough funny buzzwords? That’s definitely enough funny buzzwords!), who works as Solutions Architect for Precio Fishbone, building delightful Digital Workplaces.

He’s been a developer from 2004 (starting with PHP and Java), and he’s been working on .NET projects, Azure, Office 365, SharePoint and a lot of other stuff. He’s also Microsoft MVP for Azure.

This is his personal professional (e.g. professional, but definitely personal) blog.

mm

Понравилась статья? Поделить с друзьями:
  • Csv for excel 2007
  • Csv files not opening in excel
  • Csv files excel mac
  • Csv file opened in excel
  • Csv file open with excel