TSV (.tsv)
Background & Context

-
- 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.
- Supported expressions expr include:
-
{v1,v2,…} a single column of data {{v11,v12,…},{v21,v22,…},…} lists of rows of data array an array such as SparseArray, QuantityArray, etc. tseries a TimeSeries, EventSeries or a TemporalData object Dataset[…] a dataset Tabular[…] a tabular object - See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements


- General Import elements:
-
"Elements" list of elements and options available in this file "Rules" list of rules for all available elements "Summary" summary of the file - 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 "Tabular" table data as a Tabular object - Data descriptor elements:
-
"ColumnLabels" names of columns "ColumnTypes" association of column names and types "Schema" TabularSchema object - Import and Export use the "Data" element by default.
- Subelements for partial data import for any element elem can take row and column specifications in the form {elem,rows,cols}, where rows and cols can be any of the following:
-
n nth row or column -n counts from the end n;;m from n through m n;;m;;s from n through m with steps of s {n1,n2,…} specific rows or columns ni - Metadata elements:
-
"ColumnCount" number of columns "Dimensions" a list of number of rows and maximum number of columns "RowCount" number of rows
Options




- Import and Export options:
-
"EmptyField" "" how to represent empty fields "QuotingCharacter" "\"" 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 "QuotingCharacter".
- Double-quote characters delimiting text fields are not imported by default.
- Import options:
-
CharacterEncoding "UTF8ISOLatin1" raw character encoding used in the file "ColumnTypeDetectionDepth" Automatic number of rows used for header detection "CurrencyTokens" None currency units to be skipped when importing numerical values "DateStringFormat" None date format, given as a DateString specification "FieldSeparator" "\t" string token taken to separate columns "FillRows" Automatic whether to fill rows to the max column length "HeaderLines" Automatic number of lines to assume as headers "IgnoreEmptyLines" False whether to ignore empty lines MissingValuePattern Automatic patterns used to specify missing elements "NumberPoint" "." decimal point character "Numeric" Automatic whether to import data fields as numbers if possible "Schema" Automatic schema used to construct Tabular object "SkipInvalidLines" False whether to skip invalid lines "SkipLines" Automatic number 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:
-
Automatic try to automatically determine the number of rows to skip or use as header n n 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:
-
Alignment None how data is aligned within table columns CharacterEncoding "UTF8" raw character encoding used in the file "FillRows" False whether to fill rows to the max column length "IncludeQuotingCharacter" Automatic whether to add quotations around exported values "TableHeadings" Automatic headings for table columns and rows - Possible settings for Alignment are None, Left, Center and Right.
- "IncludeQuotingCharacter" can be set to the following values:
-
None do not enclose any values in quotes Automatic only enclose values in quotes when needed All enclose all valid values in quotes - "TableHeadings" can be set to the following values:
-
None skip column labels Automatic export column labels {"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.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Scope (8)Survey of the scope of standard use cases
Import (4)
Import metadata from a CSV file:

https://wolfram.com/xid/0ck8ux57-z7rwrf


https://wolfram.com/xid/0ck8ux57-mmpg8v

Import a TSV file as a Tabular object with automatic header detection:

https://wolfram.com/xid/0ck8ux57-e720ue

Import without headers, while skipping the first line:

https://wolfram.com/xid/0ck8ux57-2bdvi2


https://wolfram.com/xid/0ck8ux57-vz47sn

Analyze a single column of a file; start by looking at column labels and their types:

https://wolfram.com/xid/0ck8ux57-02bmbg

Get all values for one column:

https://wolfram.com/xid/0ck8ux57-1hnew


https://wolfram.com/xid/0ck8ux57-o0d2qx

Export (4)
Export a Tabular object:

https://wolfram.com/xid/0ck8ux57-n5ufob

https://wolfram.com/xid/0ck8ux57-fjoadx

Use "TableHeadings" option to remove header from a Tabular object:

https://wolfram.com/xid/0ck8ux57-cjurjr

Export a TimeSeries:

https://wolfram.com/xid/0ck8ux57-lrk4rv

https://wolfram.com/xid/0ck8ux57-dl3tiv


https://wolfram.com/xid/0ck8ux57-h897pe

Export an EventSeries:

https://wolfram.com/xid/0ck8ux57-cbmz1t

https://wolfram.com/xid/0ck8ux57-bwygpf


https://wolfram.com/xid/0ck8ux57-drt0q9

Export a QuantityArray:

https://wolfram.com/xid/0ck8ux57-demjmf


https://wolfram.com/xid/0ck8ux57-cmlb2n

Import Elements (26)
"ColumnCount" (1)
"ColumnLabels" (1)
"ColumnTypes" (1)
"Data" (6)
Import a TSV file as a 2D list of values:

https://wolfram.com/xid/0ck8ux57-nl71bm

This is also the default element:

https://wolfram.com/xid/0ck8ux57-y6nmcj

Import a single row of a TSV file:

https://wolfram.com/xid/0ck8ux57-0p4i6s

Import some specific rows of a TSV file:

https://wolfram.com/xid/0ck8ux57-fkq1ys

Import the first 3 rows of a TSV file:

https://wolfram.com/xid/0ck8ux57-48eob1

Import a single row and column from a TSV file:

https://wolfram.com/xid/0ck8ux57-q0n2ra

Import a single column from a TSV file:

https://wolfram.com/xid/0ck8ux57-4r9nt8

"Dataset" (3)
Import a TSV file as a Dataset:

https://wolfram.com/xid/0ck8ux57-sya0vk

Use "HeaderLines" to use the first row as column headers:

https://wolfram.com/xid/0ck8ux57-0qu5sd

Use "SkipLines" to only import the data of interest:

https://wolfram.com/xid/0ck8ux57-k2znlw

"Dimensions" (1)
"Grid" (1)
"RawData" (3)
Import TSV data as raw strings:

https://wolfram.com/xid/0ck8ux57-4xnxtt


https://wolfram.com/xid/0ck8ux57-cqe8yc

By default for "RawData", "Numeric"->False is used:

https://wolfram.com/xid/0ck8ux57-15pwn6

Use "Numeric"->True:

https://wolfram.com/xid/0ck8ux57-ua4ubc

By default for "RawData", "FillRows"->True is used:

https://wolfram.com/xid/0ck8ux57-eyizzh

Use "FillRows"->False:

https://wolfram.com/xid/0ck8ux57-w97jdw

"RowCount" (1)
"Schema" (1)
"Tabular" (6)
Import a CSV file as a Tabular object:

https://wolfram.com/xid/0ck8ux57-dwxov0

Use "HeaderLines" and "SkipLines" options to only import the data of interest:

https://wolfram.com/xid/0ck8ux57-ft3nmo


https://wolfram.com/xid/0ck8ux57-bgmxp6


https://wolfram.com/xid/0ck8ux57-fbogf8


https://wolfram.com/xid/0ck8ux57-i5ff6q


https://wolfram.com/xid/0ck8ux57-g0ixb

Import a single element at a given row and column:

https://wolfram.com/xid/0ck8ux57-bf2afv


https://wolfram.com/xid/0ck8ux57-l8plh


https://wolfram.com/xid/0ck8ux57-jf5yfi

Import Options (15)
CharacterEncoding (1)
The character encoding can be set to any value from $CharacterEncodings:

https://wolfram.com/xid/0ck8ux57-v2b17f

https://wolfram.com/xid/0ck8ux57-6qz5o6


https://wolfram.com/xid/0ck8ux57-2rqfrh

"ColumnTypeDetectionDepth" (1)
"CurrencyTokens" (1)
"DateStringFormat" (1)
Convert dates to a DateObject using the date format specified:

https://wolfram.com/xid/0ck8ux57-qtt0ch

By default, no conversion is happening:

https://wolfram.com/xid/0ck8ux57-gd2biv

"EmptyField" (1)
"FieldSeparator" (1)
"FillRows" (1)
For the "Data" element, row lengths are automatically preserved:

https://wolfram.com/xid/0ck8ux57-janz6s

https://wolfram.com/xid/0ck8ux57-qrqxda


https://wolfram.com/xid/0ck8ux57-mjb1ob

For the "RawData" element, a full array is imported by default:

https://wolfram.com/xid/0ck8ux57-ee0i9w

"HeaderLines" (1)
The header line is automatically detected by default:

https://wolfram.com/xid/0ck8ux57-fpqrfl

Use "HeaderLines" option when automatic header detection is incorrect:

https://wolfram.com/xid/0ck8ux57-cslkk


https://wolfram.com/xid/0ck8ux57-ffcffz


https://wolfram.com/xid/0ck8ux57-g5nren

Specify row and column headers:

https://wolfram.com/xid/0ck8ux57-xnlg5z

"IgnoreEmptyLines" (1)
MissingValuePattern (1)
By default, an automatic set of values is considered missing:

https://wolfram.com/xid/0ck8ux57-cv59lu

https://wolfram.com/xid/0ck8ux57-cyi4u

Use MissingValuePatternNone to disable missing element detection:

https://wolfram.com/xid/0ck8ux57-ep9kqm

Use string patterns to find missing elements:

https://wolfram.com/xid/0ck8ux57-rzcm8

"Numeric" (1)
Use "Numeric"->True to interpret numbers:

https://wolfram.com/xid/0ck8ux57-l7d90a

By default, everything imports as strings:

https://wolfram.com/xid/0ck8ux57-kko935

"NumberPoint" (1)
By default, "." is used to specify decimal point character for floating-point data:

https://wolfram.com/xid/0ck8ux57-b1f6a0


https://wolfram.com/xid/0ck8ux57-buv0yl

Use "NumberPoint" option to specify decimal point character for floating-point data:

https://wolfram.com/xid/0ck8ux57-k1nx6


https://wolfram.com/xid/0ck8ux57-k8y5ko

"QuotingCharacter" (1)
"Schema" (1)
Import automatically infers column labels and types from data stored in a TSV file:

https://wolfram.com/xid/0ck8ux57-pdcz1


https://wolfram.com/xid/0ck8ux57-eu5zdq

Use "Schema" option to specify column types:

https://wolfram.com/xid/0ck8ux57-ciz14m


https://wolfram.com/xid/0ck8ux57-okvxyo

"SkipLines" (1)
TSV files may include a comment line:

https://wolfram.com/xid/0ck8ux57-11s6fa


https://wolfram.com/xid/0ck8ux57-ifgthe

Skip the comment line and use the next line as a Tabular header:

https://wolfram.com/xid/0ck8ux57-qg0yaa

Export Options (7)
Alignment (1)
CharacterEncoding (1)
The character encoding can be set to any value from $CharacterEncodings:

https://wolfram.com/xid/0ck8ux57-q6fnby

https://wolfram.com/xid/0ck8ux57-kukx8w


https://wolfram.com/xid/0ck8ux57-b5ifl

"EmptyField" (1)
"FillRows" (1)
"IncludeQuotingCharacter" (1)
By default, Export only exports quotation characters for values that need them:

https://wolfram.com/xid/0ck8ux57-edbyd3

Use "IncludeQuotingCharacter"All to enclose all values in quotes:

https://wolfram.com/xid/0ck8ux57-jl1ug5

Use "IncludeQuotingCharacter"None to export all values without quotes. Note that headers are always enclosed in quotes:

https://wolfram.com/xid/0ck8ux57-e0ep1g

"QuotingCharacter" (1)
The default quoting character used for non-numeric elements is a double quote:

https://wolfram.com/xid/0ck8ux57-g8w4a5

Specify a different quoting character:

https://wolfram.com/xid/0ck8ux57-ba1wm9

Use "QuotingCharacter"->"" to export all values without quotes. Note that headers are always enclosed in quotes:

https://wolfram.com/xid/0ck8ux57-haqqdd

"TableHeadings" (1)
By default, column headers are exported:

https://wolfram.com/xid/0ck8ux57-gb6m8g

Use "TableHeadings"None to skip column headers:

https://wolfram.com/xid/0ck8ux57-f9xvg7

Export data using custom column headers:

https://wolfram.com/xid/0ck8ux57-895ej8

Export data using custom column and row headers:

https://wolfram.com/xid/0ck8ux57-69ahdp

Applications (1)Sample problems that can be solved with this function
Export a list of European countries and their populations to a TSV file:

https://wolfram.com/xid/0ck8ux57-wlpbop

https://wolfram.com/xid/0ck8ux57-hdppu8


https://wolfram.com/xid/0ck8ux57-ycufr4

Import the data back and convert to expressions:

https://wolfram.com/xid/0ck8ux57-sf3ga8

Possible Issues (12)Common pitfalls and unexpected behavior
If all rows in the file do not have the same number of columns, some rows may be considered as invalid:

https://wolfram.com/xid/0ck8ux57-66wo5p

Entries of the format "nnnDnnn" or "nnnEnnn" are interpreted as numbers with scientific notation:

https://wolfram.com/xid/0ck8ux57-coz9h9

Use the "Numeric" option to override this interpretation:

https://wolfram.com/xid/0ck8ux57-ma29p

Numeric interpretation may result in a loss of precision:

https://wolfram.com/xid/0ck8ux57-my6e32

Use the "Numeric" option to override this interpretation:

https://wolfram.com/xid/0ck8ux57-38iqda

Starting from Version 14.2, currency tokens are not automatically skipped:

https://wolfram.com/xid/0ck8ux57-kcplae

Use the "CurencyTokens" option to skip such tokens:

https://wolfram.com/xid/0ck8ux57-rcjbb

Starting from Version 14.2, quoting characters are added when the column of integer values contains numbers greater than Developer`$MaxMachineInteger:

https://wolfram.com/xid/0ck8ux57-chddnz

Use "IncludeQuotingCharacter"->None to get the previous result:

https://wolfram.com/xid/0ck8ux57-fy84hr

Starting from Version 14.2, some strings are automatically considered missing:

https://wolfram.com/xid/0ck8ux57-daqhd9

Use MissingValuePatternNone to override this interpretation:

https://wolfram.com/xid/0ck8ux57-enhjv9

Starting from Version 14.2, real numbers with 0 fractional part are exported as integers:

https://wolfram.com/xid/0ck8ux57-ilg5c5

Use "Backend"->"Table" to get the previous result:

https://wolfram.com/xid/0ck8ux57-oa5c0u

Starting from Version 14.2, integers greater than Developer`$MaxMachineInteger are imported as real numbers:

https://wolfram.com/xid/0ck8ux57-idfu07


https://wolfram.com/xid/0ck8ux57-4gqow

Use "Backend"->"Table" to get the previous result:

https://wolfram.com/xid/0ck8ux57-d15g2n

Starting from Version 14.2, date and time columns of Tabular objects are exported using DateString:

https://wolfram.com/xid/0ck8ux57-rapyb


https://wolfram.com/xid/0ck8ux57-ec3ic3


https://wolfram.com/xid/0ck8ux57-fyjbmz

Use "Backend"->"Table" to get the previous result:

https://wolfram.com/xid/0ck8ux57-jv3aky

Some TSV data generated from older versions of the Wolfram Language may have incorrectly delimited text fields and will not import as expected in Version 11.2 or higher:

https://wolfram.com/xid/0ck8ux57-q239r3

Using "QuotingCharacter""" will give the previously expected result:

https://wolfram.com/xid/0ck8ux57-zeueaf

The top-left corner of data is lost when importing a Dataset with row and column headers:

https://wolfram.com/xid/0ck8ux57-i566gf

Dataset may look different depending on the dimensions of the data:

https://wolfram.com/xid/0ck8ux57-zae5qn


https://wolfram.com/xid/0ck8ux57-7m0b0l


https://wolfram.com/xid/0ck8ux57-ekgmw


https://wolfram.com/xid/0ck8ux57-fqkjge
