TSV (.tsv)


    • MIME type: text/tab-separated-values
    • TSV tabular data format.
    • Stores records of numerical and textual information as lines, using tab characters to separate fields.
    • TSV is an acronym for Tab-Separated Values.
    • Plain text format.
    • Similar to CSV.

Import & Export

  • Import["file.tsv"] returns a list of lists containing strings and numbers, representing the rows and columns stored in the file.
  • Import["file.tsv",elem] imports the specified element from a TSV file.
  • Import["file.tsv",{elem,sub1,}] imports subelements, specifically useful for partial data import.
  • The import format can be specified with Import["file","TSV"] or Import["file",{"TSV",elem,}].
  • Export["file.tsv",expr] creates a TSV file from expr, using the InputForm of non-numeric elements at the second level.
  • Export["file.tsv",expr] also works for structured input such as Dataset and TimeSeries.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the TSV format.

Notebook Interface

  • Save Selection As exports the selected part of a notebook as a TSV file.

Import Elements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
    "Summary"summary of file size and dimensions
  • Data representation elements:
  • "Data"two-dimensional array
    "Grid"table data as a Grid object
    "RawData"two-dimensional array of strings
    "Dataset"table data as a Dataset
  • Import and Export use the "Data" element by default.
  • For partial data import, any data representation element elem can take row and column specifications in the form {elem, rows, cols}, where rows and cols can be any of the following:
  • nnth row or column
    -ncounts from the end
    n;;mfrom n through m
    n;;m;;sfrom n through m with steps of s
    {n1,n2,}specific rows or columns ni
  • Metadata elements:
  • "Dimensions"a list of number of rows and maximum number of columns
    "MaxColumnCount"maximum number of columns
    "RowCount"number of rows


  • Import and Export options:
  • "EmptyField"""how to represent empty fields
    "TextDelimiters""\""character used to delimit non-numeric fields
  • Data fields containing commas and line separators are typically wrapped in double-quote characters. By default, Export uses double-quote characters as delimiters. Specify a different character using "TextDelimiters".
  • Double-quote characters delimiting text fields are not imported by default.
  • Import options:
  • CharacterEncoding"UTF8ISOLatin1"raw character encoding used in the file
    "CurrencyTokens"{{"$", "£", "¥", "€"}, {"c", "¢", "p", "F"}}currency units to be skipped when importing numerical values
    "DateStringFormat"Nonedate format, given as a DateString specification
    "FillRows"Automaticwhether to fill rows to the max column length
    "HeaderLines"0number of lines to assume as headers
    "IgnoreEmptyLines"Falsewhether to ignore empty lines
    "NumberPoint""."decimal point string
    "Numeric"Automaticwhether to import data fields as numbers if possible
    "SkipLines"0number of lines to skip at the beginning of the file
  • By default, Import attempts to interpret the data as "UTF8" encoded text. If any sequence of bytes stored in the file cannot be represented in "UTF8", Import uses "ISOLatin1" instead.
  • With CharacterEncoding -> Automatic, Import will attempt to infer the character encoding of the file.
  • Possible settings for "HeaderLines" and "SkipLines" are:
  • nn rows to skip or to use as Dataset headers
    {rows,cols}rows and columns to skip or to use as headers
  • Import converts table entries formatted as specified by "DateStringFormat" to a DateObject.
  • Export options:
  • AlignmentNonehow data is aligned within table columns
    CharacterEncoding"UTF8"raw character encoding used in the file
    "FillRows"Falsewhether to fill rows to the max column length
    "TableHeadings"Noneheadings for table columns and rows
  • Possible settings for Alignment are None, Left, Center, and Right.
  • "TableHeadings" can be set to the following values:
  • Noneno labels
    Automaticgives successive integer labels for columns and rows
    {"col1","col2",}list of column labels
    {rhead,chead}specifies separate labels for the rows and columns
  • Export encodes line separator characters using the convention of the computer system on which the Wolfram Language is being run.


open all close all

Basic Examples  (3)

Import a TSV file:

Click for copyable input

Import a TSV file as a Dataset with headers:

Click for copyable input

Export an array of expressions to TSV:

Click for copyable input
Click for copyable input

Scope  (5)

Import Elements  (17)

Import Options  (10)

Export Options  (7)

Applications  (1)

Possible Issues  (5)

Introduced in 1999
Updated in 2019