# @stenway/tbl

> Serialize and deserialize TBL documents

Latest version **1.1.1** (published 2023-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @stenway/tbl
pnpm add @stenway/tbl
yarn add @stenway/tbl
bun add @stenway/tbl
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2023-09-04 |
| First published | 2022-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 46.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Stefan John |
| Maintainers | stenway |
| Keywords | table, csv, tsv, wsv, sml, meta data, data format, data, file format, binarytbl, btbl, tbl, binary table format, tables, tbls, binarysml, bsml, bs1 |

## Links

- npm: https://www.npmjs.com/package/@stenway/tbl
- Repository: https://github.com/Stenway/TBL-TS
- Homepage: https://www.simpleml.com
- Issues: https://github.com/Stenway/TBL-TS/issues
- npm.io page: https://npm.io/package/@stenway/tbl

## Dependencies (2)

- [@stenway/sml](https://npm.io/package/@stenway/sml.md) ^1.1.0
- [@stenway/reliabletxt](https://npm.io/package/@stenway/reliabletxt.md) ^1.1.0

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2023-09-04
- 1.1.0 — 2023-09-04
- 0.8.0 — 2023-08-22
- 0.7.0 — 2023-08-17
- 0.2.0 — 2023-05-18
- 0.1.0 — 2023-02-11
- 0.0.1 — 2022-10-29

## README

# TBL

## About TBL

TBL is a data table format based on [SML](https://www.npmjs.com/package/@stenway/sml) - the Simple Markup Language. TBL is a modern and robust alternative to CSV. It has only a minimal set of rules and solves
the main problems of CSV (watch [this video](https://www.youtube.com/watch?v=mGUlW6YgHjE) for more details on that). It's human friendly and can produce documents that are beautifully formatted
and readable, even without specific tools, just opened in a text editor. Here is an example TBL document:

```
Table
  Meta
    Title       "My Table"
    Description "This is a description of my table"		
  End
  FirstName      LastName  Age PlaceOfBirth
  William        Smith     30  Boston
  Olivia         Jones     27  "San Francisco"
  Lucas          Brown     -   Chicago          # Age missing
  "James Elijah" Wilson    20  "New York City"
  Elizabeth      Miller                         # Data missing
  Victoria       Davis     22  Austin
End
```

It has support for meta data, can differentiate between null values and empty values, and can contain comments.
TBL **doesn't need to bother about encoding and decoding** anymore, because it relies on [ReliableTXT](https://www.reliabletxt.com), which takes care of that aspect (see also the NPM package [reliabletxt](https://www.npmjs.com/package/@stenway/reliabletxt)).

A TBL document represents a single table. If you need to embed multiple tables into one document, TBLS comes into play:

```
Tables
  Table
    Column1 Column2
    Value1  Value2
  End
  Table
    ColumnA ColumnB
    ValueA  ValueB
  End
End
```

Find out what can be done with TBL and TBLS on the official [YouTube channel from Stenway](https://www.youtube.com/@stenway) and get started with videos like:
* [TBL - A Simple Table Format with SML](https://www.youtube.com/watch?v=BkASqYznmE8)
* [TBLS - Multiple Tables in ONE File](https://www.youtube.com/watch?v=66qRRRVKbUI)
* [Stenway Text File Format Stack](https://www.youtube.com/watch?v=m7Z0mrcFeCg)
* [RSS to TBLS](https://www.youtube.com/watch?v=EmYF6RkSpIM)
* [Opening WSV, TBL and TBLS Files with LibreOffice](https://www.youtube.com/watch?v=S4GbszMYAoM)
* [Stop Using CSV !](https://www.youtube.com/watch?v=mGUlW6YgHjE)
* [Writing SML on a typewriter](https://www.youtube.com/watch?v=sa1yln1kH1k)

## About this package

This package provides functionality to handle the **parsing and serialization** of TBL and TBLS documents. It also provides functionality to encode and decode the binary version of TBL, which is called BinaryTBL.
The package **works both in the browser and Node.js**, because it does not require environment specific functionality.
If you want to **read and write TBL files** using Node.js's file system module, you can use the **[tbl-io](https://www.npmjs.com/package/@stenway/tbl-io)** package.
The **[tbl-browser](https://www.npmjs.com/package/@stenway/tbl-browser)** package on the other hand
offers functionality to easily provide TBL documents as downloadable files.

## Getting started

We first have to install the Stenway TBL package with the npm install command.

```
npm install @stenway/tbl
```

Then import the TblDocument class and create a new TblDocument object by calling
the static parse method:

```ts
import { TblDocument } from "@stenway/tbl"
const document = TblDocument.parse("Table\nColumn1 Column2\nValue1 Value2\nEnd")
console.log(document)
```

Add a new row with the addRow method like this:

```ts
document.addRow(["ValueA", "ValueB"])
```

More documentation about the other classes, methods and properties will follow.

## BinaryTBL

BinaryTBL is the binary representation of TBL documents. It's based on BinarySML.
You can encode a document to BinaryTBL with the toBinaryTbl method and decode it
with the static method fromBinaryTbl:

```ts
const document = TblDocument.parse(`Table\nColumn1 Column2\nValue1 Value2\nEnd`)
const bytes = document.toBinaryTbl()
const decodedDocument = SmlDocument.fromBinaryTbl(bytes)
```

---
_Source: https://npm.io/package/@stenway/tbl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
