Up: Structured Data in Oil

Now named QTT: Quoted, Typed Tables

QTT is an interchange format for tables that's a graceful upgrade of TSV. A TSV file is a valid QTT file.

It uses QSN (Quoted String Notation) as a building block.

Short Description

TSV2 is a textual interchange format for tables, like JSON is for nested data. It's most easily described as a TSV file with some nice properties:

In canonical form, a TSV2 file is a valid UTF-8 text file. There may be reasons to use non-canonical forms (e.g. for compatibility with old TSV readers).

Example

NOTE: → are tab characters (written in HTML as →).

The default column type is string.

This example is inconsistent to illustrate the principle that single quotes are optional in some cases but required in others. They're recommended when a field contains spaces, but required when a field contains newlines or tabs.

What consumes it?

What emits it?

Why not CSV?

A line is not a record in CSV, e.g.

"record
with
spaces",10

is a single record. This doesn't work well with line-oriented shell tools.

Also, CSV in practice tends to be ill-specified. (e.g. hardware outputs really broken CSV files.)

Why not TSV?

Why Single Quotes instead of Double Quotes?

Because JSON uses double quotes, and JSON represents unicode strings. TSV2 represents byte strings, which can be utf-8 encoded.

Is it compatible with TSV?

Strictly speaking, no. Hence the "major version number bump". However:

Types

Based on JSON primitive types, but less tied to JavaScript:

What's the difference between string and bytes columns?

Nothing as far as the TSV2 format is concerned. string is an indication to the language's library to try to decode utf-8 and escape sequences into a string data structure, if applicable. (e.g. Python, Java, and JavaScript provide random code point access; Go and Rust use UTF-8 internally.)

Columns Other than String / Bytes Follow JSON Format

See the "regular expressions" at json.org. We use true, false, and null.

Required Validations

Canonicalization

Relationship to Programming Languages

Links

Issues / Notes