How to Open a CSV File With a Different Delimiter

Open a CSV that uses semicolons, tabs, pipes or another separator in Excel, LibreOffice Calc, Google Sheets or Python, and check that columns and values stay intact.

A CSV file is plain text where each line is a record and the fields are separated by a delimiter. The name means "comma-separated values," but many files use a semicolon, a tab, a pipe (|) or another character instead. If a program assumes the wrong delimiter, the whole row lands in one column or splits in the wrong places. This guide explains what delimiter detection does, how to choose the delimiter yourself in common tools, and how to confirm the data arrived unchanged.

What delimiter detection does for your file

A CSV "dialect" is the set of formatting rules a file follows: which character separates fields, which character quotes fields that contain the separator, and how line breaks are written. Dialect detection reads a sample of the text and guesses those rules. The input is the raw text file. The output is a table in which each field sits in its own column. The original file is not modified unless you save over it.

Detection is a guess based on patterns, not a guarantee. It works best when every line has the same number of fields. It can fail when the sample is short, when a field contains the delimiter without quotes, or when two candidate characters both appear regularly. When the guess is wrong, set the delimiter manually.

Identify the delimiter first

Open the file in a plain-text editor, not a spreadsheet, and look at the first few lines. The character that repeats between values on every line is usually the delimiter. The samples below are illustrative.

Example of a semicolon-delimited file. The decimal commas are a common pattern in locales that write numbers like 3,50:

id;name;price
001;Widget, small;3,50
002;Gadget;12,00

Example of a tab-delimited file. Tabs are invisible in most editors, so each tab is shown here as <TAB>:

id<TAB>name<TAB>price
001<TAB>Widget, small<TAB>3.50

In the first example, a program that splits on commas would break "Widget, small" and "3,50" into extra columns. This is the most common reason a CSV opens incorrectly. Many editors can display tabs and other whitespace if you turn on a "show invisible characters" or similar option.

Microsoft Excel

When you double-click a CSV, Excel typically splits it using the list separator from your system's regional settings, with no chance to choose another. To pick the delimiter, import the file instead of opening it:

  • Open a blank workbook.
  • Go to the Data tab and choose From Text/CSV.
  • Select the file. A preview appears with a Delimiter dropdown.
  • If the preview is wrong, choose Semicolon, Tab, Comma or Custom and enter the character.
  • Check the File Origin (encoding) setting if letters with accents or non-Latin text look garbled.
  • Choose Load, or choose Transform Data to adjust column types before loading.

The import may convert columns automatically. For example, it can drop leading zeros from IDs like 001 or reinterpret dates. To keep values exactly as written, use Transform Data and set those columns to Text before loading. You can also change the data type detection setting in the import preview if your version offers one. Menu labels differ between Excel versions and platforms, so the names above may not match yours exactly.

LibreOffice Calc

Calc shows a Text Import dialog whenever you open a CSV:

  • Open the file with File > Open.
  • In the Text Import dialog, under Separator Options, select Separated by.
  • Tick the correct separator (Tab, Comma, Semicolon, Space) or tick Other and type the character.
  • Set the String delimiter, usually the double quote ("), so quoted fields that contain the separator stay whole.
  • Check Character set if text appears garbled.
  • To protect values such as leading zeros, click the column in the preview and set its type to Text.
  • Confirm with OK.

Google Sheets

  • Open a spreadsheet and choose File > Import.
  • Upload the CSV file.
  • Under Separator type, choose Detect automatically, Tab, Comma or Custom. With Custom, enter the character.
  • Decide whether to convert text to numbers, dates and formulas. Turning conversion off keeps values as written.
  • Import the data.

Python

The standard library's csv module includes a Sniffer class. It guesses the dialect from a sample of text and returns a dialect object you can pass to the reader. The snippet below is an illustrative example that has not been run here. The delimiters argument limits the guess to the characters you expect.

import csv

with open("data.csv", newline="", encoding="utf-8") as f:
    sample = f.read(4096)
    f.seek(0)
    dialect = csv.Sniffer().sniff(sample, delimiters=";,\t|")
    print("Detected delimiter:", repr(dialect.delimiter))
    for row in csv.reader(f, dialect):
        print(row)

If you already know the delimiter, skip detection and pass it directly, for example csv.reader(f, delimiter=";"). In pandas, read_csv accepts sep=";" for a known delimiter. Passing sep=None together with engine="python" lets pandas try to detect it. To keep IDs and similar fields unchanged, read them as text with dtype=str (illustrative):

import pandas as pd

df = pd.read_csv("data.csv", sep=";", dtype=str, encoding="utf-8")

Command line

For a quick look, awk can split on a chosen delimiter. This illustrative command prints the second field of each line. Note that awk does not understand CSV quoting, so a quoted field containing a semicolon will split incorrectly:

awk -F';' '{ print $2 }' data.csv

Dedicated CSV tools, such as csvkit, accept an input delimiter option (-d) and do handle quoting. csvkit's csvformat can rewrite a file with a different delimiter. For example, this converts a semicolon-delimited file to comma-delimited output in a new file:

csvformat -d ';' data.csv > data_comma.csv

Verify the result

  • Every row has the same number of columns as the header. Extra or missing columns usually mean the wrong delimiter or broken quoting.
  • Fields that contain the delimiter inside quotes, such as "Widget, small", remain in one cell.
  • Leading zeros, long numeric IDs and codes match the original text.
  • Decimal numbers are read correctly. A value like 3,50 may need a locale setting that uses the comma as the decimal separator, or it may need to stay as text.
  • Accented and non-Latin characters display correctly. If they do not, re-import with the right encoding, often UTF-8.
  • The last rows are present. Compare the row count with the number of lines in the text file, keeping in mind that quoted fields can contain line breaks.

Limits of this guide

No version-specific documentation or test results were supplied for this article. Menu names, default behaviors and detection accuracy vary by application version, platform and regional settings. Treat the steps as general guidance and check them against the tool you are using. The code examples are illustrative and have not been run against real files here.