What is a delimiter?

While it may not be the most enthralling of topics, it's time to define one of the most core components of a CSV file:

What is a delimiter?
Simply put: a delimiter is the character that separates fields in your CSV file. It is what the computer reads as a "separator" of sorts, giving structure to your file. Without it, your file would be one, verrrry long read with no organizational structure at all.

Sometimes, it's best explained visually:
Here's what it looks like when a comma is used as the delimiter.

Those commas in the example above are what separate the text into separate fields. So, when you open in spreadsheet, it looks like this:

A nice, organized table of separate fields.
If there was no delimiter, when you go to open your file, it would look like this:

See how all your text is now combined in one column?
Let's get back to the definition. If you recall from our article defining CSV - a CSV file is a comma separated values file. The delimiter is right there in the title!

However, before you think that is all there is to say...CSV file format is not actually that standardized. There are other choices for the delimiter. But, for simplicity's sake, the name "CSV" is still used, no matter what the delimiter is.

Other common delimiters are:

  • semi-colon
  • tab
  • pipe (vertical bar)
  • space
While it may seem annoying that a CSV can in fact be separated by something other than a comma, it is actually very convenient. Say, for example, your data contains commas in places that are not supposed to be used as separators (addresses for example, or currency, etc.). This can be confusing to the computer program trying to read your data - and is in fact why quotation marks are used as text qualifiers, to help solve this problem. Instead of using commas both within your text fields and as a delimiter, you can opt to use another delimiter - one that is not used elsewhere within your data.

You can see this more practically when looking at the delimiter defaults by locale. For example, in Europe it is much more common to see the default delimiter as a semi-colon, because commas are used to separate decimals (in currency, for example).

To bring us back to the core concept:

The delimiter in your CSV is the character (comma or otherwise) that separates the data in your file into distinct fields. Practically speaking, it is what allows you to open your file in a spreadsheet and view the data in nicely organized columns and rows, and even what allows programs to import data from your CSV and place the data into the correct fields in your database. Delimiters are the key to the entire structure of CSV!