Integrating TSV files [b] [d] [p] [q]

Tab-separated values (TSV) is a simple and widely supported file format for tabular data. It can be used to export data from a database and can be imported into a spreadsheet application. TSV files can be integrated easily and flexibly in Aneamal as well and are displayed as table on the webpage.

How to

See Integrating files and choose one of the following four file tokens for TSV files:

[b]
This token is the basic choice for any regular TSV file. Records of the TSV file correspond to rows in the generated table.
[d]
Choose this token, if you want Aneamal markup inside the TSV file to be processed. Only phrase markup is recognized. Pairwise marks must have their left and right mark within the same field of the TSV file.
[p]
Use this token to transpose the table generated from the TSV file. Records of the TSV file correspond to columns of a generated transposed table.
[q]
Use this token, if you want Aneamal markup inside the TSV to be processed and the generated table to be transposed.

Examples

The first example integrates a linked tab-separated values file saturn-mission.tsv.

[b]->/stuff/saturn-missions.tsv
Mission Type Launch
Pioneer 11 flyby 1973-04-06
Voyager 2 flyby 1977-08-20
Voyager 1 flyby 1977-09-05
Cassini orbiter 1997-10-15

The second example demonstrates how to reverse the order of records from a TSV file automatically through partial loading. The query 1,-1:2 tells the Aneamal Translator to load the file’s first line first, followed by the range of lines from the last to the second line.

[b]->/stuff/saturn-missions.tsv?1,-1:2
Mission Type Launch
Cassini orbiter 1997-10-15
Voyager 1 flyby 1977-09-05
Voyager 2 flyby 1977-08-20
Pioneer 11 flyby 1973-04-06

The third example displays the same file differently: it transposes the table using the file token [p]. Hence the columns from the first example become rows and rows from the first example become columns here:

[p]->/stuff/saturn-missions.tsv
Mission Pioneer 11 Voyager 2 Voyager 1 Cassini
Type flyby flyby flyby orbiter
Launch 1973-04-06 1977-08-20 1977-09-05 1997-10-15

The fourth example loads a file mercury-missions.tsv which contains Aneamal hints that spell out abbreviations. The file is loaded with a [d] token so that the hints are processed. Depending on the device and browser used for viewing the webpage, the hints could be shown as tooltip when the cursor hovers over an abbreviation.

[d]->/stuff/mercury-missions.tsv
Mission Operator Launch
Mariner 10 NASA/JPL 1973-11-03
MESSENGER NASA 2004-08-03
BepiColombo ESA, JAXA 2018-10-20

The last example uses the [q] file token to transpose the table and to interpret Aneamal marks inside it, in this case for math strings. The example uses an embedded instead of a linked file and has a caption.

[q]
|$n$	$f^{(n)}(x)$
|$1$	$\ln(x)$
|$2$	$x^{-1}$
|$3$	$-x^{-2}$
|$4$	$2x^{-3}$
|$5$	$-6x^{-4}$
derivatives of $f(x)=x\ln(x)-x$
n 1 2 3 4 5
f^{(n)}(x) \ln(x) x^{-1} -x^{-2} 2x^{-3} -6x^{-4}
derivatives of f(x)=x\ln(x)-x

For developers

Integrated TSV files are wrapped in an HTML table element when converted to a webpage. The names from the TSV nameline become HTML th elements, the fields from the records are translated to td elements. A number of other elements and attributes are involved. See how the first example is translated to HTML:

<table>
<thead>
<tr>
<th scope='col'>Mission</th>
<th scope='col'>Type</th>
<th scope='col'>Launch</th>
</tr>
</thead>
<tbody>
<tr>
<td>Pioneer 11</td>
<td>flyby</td>
<td>1973-04-06</td>
</tr>
<tr>
<td>Voyager 2</td>
<td>flyby</td>
<td>1977-08-20</td>
</tr>
<tr>
<td>Voyager 1</td>
<td>flyby</td>
<td>1977-09-05</td>
</tr>
<tr>
<td>Cassini</td>
<td>orbiter</td>
<td>1997-10-15</td>
</tr>
</tbody>
</table>

The HTML structure for a transposed TSV file differs of course. Here is the generated HTML code for the third example:

<table>
<colgroup>
<colgroup span='4'>
<tbody>
<tr>
<th scope='row'>Mission</th>
<td>Pioneer 11</td>
<td>Voyager 2</td>
<td>Voyager 1</td>
<td>Cassini</td>
</tr>
<tr>
<th scope='row'>Type</th>
<td>flyby</td>
<td>flyby</td>
<td>flyby</td>
<td>orbiter</td>
</tr>
<tr>
<th scope='row'>Launch</th>
<td>1973-04-06</td>
<td>1977-08-20</td>
<td>1977-09-05</td>
<td>1997-10-15</td>
</tr>
</tbody>
</table>

Further reading