Tab-separated values

{{Short description|Text file format}}

{{Infobox file format

| name = Tab-separated values

| icon = TsvDelimited001.svg

| icon_size = 128px

| logo =

| screenshot =

| caption =

| _noextcode = on

| extension = {{code|.tsv}}, {{code|.tab}}{{Cite web|url=https://www.ed.ac.uk/information-services/research-support/research-data-service/after/data-repository/choosing-file-formats|title=Choose the best file formats|publisher=University of Edinburgh|author=U of Edin. Research Data Support Team|at=§ Formats we recommend|access-date=2023-05-23}}

| mime = text/tab-separated-values

| type code =

| uniform type = public.tab-separated-values-text

| conforms to = public.delimited-values-text

| magic =

| owner = University of Minnesota Internet Gopher Team


Internet Assigned Numbers Authority

| type = Delimiter-separated values format

| released = {{circa|{{start date and age|1993|06}}}}

| latest release version =

| latest release date =

| genre = multiplatform, serial data streams

| container for = database information organized as field separated lists

| contained by =

| extended from =

| extended to =

| standard = IANA MIME type

| url =

}}

{{use dmy dates|date=May 2023}}Tab-separated values (TSV) is a simple, text-based file format for storing tabular data.{{Cite web |title=How To Use Tab Separated Value (TSV) files |url=https://www.imf.org/external/help/tsv.htm |access-date=2023-02-01 |publisher=International Monetary Fund}} Records are separated by newlines, and values within a record are separated by tab characters. The TSV format is thus a delimiter-separated values format, similar to comma-separated values.

TSV is a simple file format that is widely supported, so it is often used in data exchange to move tabular data between different computer programs that support the format. For example, a TSV file might be used to transfer information from a database to a spreadsheet.

Example

The head of the Iris flower data set can be stored as a TSV using the following plain text (note that the HTML rendering may convert tabs to spaces):

Sepal length Sepal width Petal length Petal width Species

5.1 3.5 1.4 0.2 I. setosa

4.9 3.0 1.4 0.2 I. setosa

4.7 3.2 1.3 0.2 I. setosa

4.6 3.1 1.5 0.2 I. setosa

5.0 3.6 1.4 0.2 I. setosa

The TSV plain text above corresponds to the following tabular data:

class="wikitable"

! Sepal length

! Sepal width

! Petal length

! Petal width

! Species

5.1

| 3.5

| 1.4

| 0.2

| I. setosa

4.9

| 3.0

| 1.4

| 0.2

| I. setosa

4.7

| 3.2

| 1.3

| 0.2

| I. setosa

4.6

| 3.1

| 1.5

| 0.2

| I. setosa

5.0

| 3.6

| 1.4

| 0.2

| I. setosa

Character escaping

The IANA media type standard for TSV achieves simplicity by simply disallowing tabs within fields.{{Sfn|Lindner|1993}}

Since the values in the TSV format cannot contain literal tabs or newline characters, a convention is necessary for lossless conversion of text values with these characters. A common convention is to perform the following escapes:{{cite web |last=Dusek |first=Jason |date=2014-05-06 |title=Linear TSV: simple, line-oriented, tabular data |url=http://dataprotocols.org/linear-tsv/ |website=Data Protocols - Open Knowledge Foundation |edition=v1.0β}}{{cite web |last=Dolan |first=Stephen |date=2018-11-01

|title={{mono|jq}} Manual |url=https://stedolan.github.io/jq/manual/ |access-date=2023-05-23 |website={{mono|jq}}}}

class="wikitable"

|+

!escape sequence

!meaning

\n

|line feed

\t

|tab

\r

|carriage return

\\

|backslash

Another common convention is to use the CSV convention from {{IETF RFC|4180}} and enclose values containing tabs or newlines in double quotes. This can lead to ambiguities.{{Cite book |last=Miller |first=Rob |url=https://books.google.com/books?id=dg9QDwAAQBAJ&pg=PT94 |title=Text Processing with Ruby: Extract Value from the Data That Surrounds You |date=2015-09-22 |publisher=Pragmatic Bookshelf |isbn=978-1-68050-492-7 |pages=94 |language=en}}{{Cite book |last1=Giuseppini |first1=Gabriele |url=https://books.google.com/books?id=vnIXo-yUT2gC |title=Microsoft Log Parser Toolkit: A Complete Toolkit for Microsoft's Undocumented Log Analysis Tool |last2=Burnett |first2=Mark |date=2005-02-10 |publisher=Elsevier |isbn=978-0-08-048939-1 |pages=311 |language=en}}

Line endings

Records are typically separated by a line feed, as is typical for Unix platforms, or a carriage return and line feed, as is typical for Microsoft platforms. Some programs may expect the latter. The de-facto specification{{cite web |url=https://www.iana.org/assignments/media-types/text/tab-separated-values|title=IANA: text/tab-separated-values}} specifies that records are separated by an {{mono|EOL}}, but does not specify any specific newline.

See also

References

{{reflist|refs=

{{cite web |url=https://developer.apple.com/documentation/uniformtypeidentifiers/uttype/3551577-tabseparatedtext |title=tabSeparatedText |work=Apple Developer Documentation: Uniform Type Identifiers |publisher=Apple Inc|ref={{harvid|Apple UTI}}|access-date=2023-05-23}}

}}

= Sources =

  • {{cite web|url=https://www.loc.gov/preservation/digital/formats/fdd/fdd000533.shtml|title=TSV — Tab-Separated Values|publisher=Library of Congress|id=fdd000533|edition=11 February 2021|access-date=2023-05-23|ref={{harvid|Library of Congress}}}}
  • {{cite web|last=Lindner |first=Paul |date=June 1993 |title={{mono|text/tab-separated-values}}|trans-title=Definition of tab-separated-values (tsv) |url=https://www.iana.org/assignments/media-types/text/tab-separated-values |access-date=2023-05-23 |work=Assigned Media Types Registry|others=IANA |publisher=University of Minnesota Internet Gopher Team |publication-place=Minnesota}}
  • {{cite web|url=https://www.imf.org/external/help/tsv.htm|title=How To Use Tab Separated Value (TSV) Files|archive-url=https://web.archive.org/web/20070112194522/www.imf.org/external/help/tsv.htm|url-status=live|archive-date=2007-01-12}}

Further reading

  • {{Cite web|url=https://jkorpela.fi/TSV.html|title=Tab Separated Values (TSV): a format for tabular data exchange|last=Jukka|first=Korpela|date=2000-09-01|edition=12 February 2005|access-date=2023-05-23}}
  • {{Cite book|last=Welinder|first=Morten|date=2012-12-19|section-url=https://help.gnome.org/users/gnumeric/stable/gnumeric.html#file-format-tab|section=§14.2.3 — Text File Formats|title=The Gnumeric Manual|edition=v1.12|access-date=2023-05-23}}

Category:Spreadsheet file formats

Category:Delimiter-separated format

Category:Computer file formats