logo

Why tabs?

There are four good reasons to use the tab character to separate (or delimit) the fields in a data table. In a nutshell, you avoid comma hassles, you can display fields easily in a text editor or terminal, you can move data between text and spreadsheet quickly, and you don't have to specify a delimiter for some command-line tools.

Here's the long version:

Comma hassles
Comma-separated value (or 'CSV') text files can be troublesome because a comma within a data item is no different from a comma used to separate data items.

CSV trouble is usually avoided by double-quoting data items. Sometimes only data items containing commas are double-quoted, sometimes data items with spaces are also double-quoted, and sometimes all data items are double-quoted:

"Chifley, Dean",45 Top Road,Wombat Hollow,NSW
"Chifley, Dean","45 Top Road","Wombat Hollow",NSW
"Chifley, Dean","45 Top Road","Wombat Hollow","NSW"

An additional complication is that if double quotes occur within data items in a CSV, they're also double quoted:

"Smith, Andrew","0417 563 294",""The Croft"",Middleboro,Vic

Unlike commas, tabs are unlikely to be present within data items, and a simpler alternative to CSV is TSV. It doesn't matter how many commas or spaces there are in a TSV file, they won't be mistaken for field delimiters, and commas and spaces don't need to be double-quoted.

Displaying fields
Tabs make it easier to see fields as separate blocks when a data table is viewed in a text editor or a terminal. In the screen shot on the 'data table' page, note how the Geany text editor shows the tab character as a light-coloured arrow. The text editor Gedit does the same with its 'Draw Spaces' plug-in.

You can get clear separation of tab-separated data items in a terminal by adjusting the default tab spacing with the tabs command. In this screenshot from my terminal, I set the tab spacing to 12 characters before opening the data table (called contacts):

contacts terminal

Text-spreadsheet interchange
Spreadsheet programs use the tab character as field delimiter in copy/pasting, which is a great time-saver when swapping between text-only and spreadsheet format. See this page for details.

Utilities with tabs as default
The tab character is the default field separator for the cut and paste commands, so you can use those commands without specifying a delimiter. Both commands are very handy in managing data tables.