Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oooutlk/tsv
tab-seperated-values for serialization/deserialization
https://github.com/oooutlk/tsv
rust rust-crate rust-library tsv
Last synced: about 2 months ago
JSON representation
tab-seperated-values for serialization/deserialization
- Host: GitHub
- URL: https://github.com/oooutlk/tsv
- Owner: oooutlk
- License: mit
- Created: 2018-08-16T08:04:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-26T06:11:33.000Z (over 6 years ago)
- Last Synced: 2024-10-07T16:47:51.030Z (3 months ago)
- Topics: rust, rust-crate, rust-library, tsv
- Language: Rust
- Size: 19.5 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
The tsv project introduces a new format for data serialization/deserialization, which is text-based and deals with tabular data.
# The problem
At [serde](https://serde.rs)'s point of view, the classic [tsv](https://www.iana.org/assignments/media-types/text/tab-separated-values) is only applicable to the schema of (a sequence of) a `struct` composed of primitives( integer, floats, strings etc). The specification has to be extended to allow arbitrary schemas, such as a `struct` of a `struct`.
# The solution
This project extends the spec by placing sequences in columns. See tsv-spec.txt for specification.
It uses serde crate for serialization/deserialization, and reflection crate for generating column names and dealing with `enum`s.## Notice
If you impl Serialize/Deserialize for your types to tell serde they are sequences/maps, do make sure their `schemata()` and `Vec::schemata()`/`HashMap::schemata()` are isomorphic.
# Pros
1. Simple.
The only requirement for end users to use tsv files is to understand what a table is. It is deadly simple as a configuration file format for non-technical users.2. Available.
You can use Microsoft Excel, OpenOffice/LibreOffie Calc and text editors that support [elastic tabstops](http://nickgravgaard.com/elastic-tabstops/) to view/edit tsv files.
And it is easy to write tsv by hand if you have read all the 63 lines of the spec.# Cons
1. Not efficiency-oriented.
2. Not self-descripting.
# License
Under MIT.
# Example
A cargo configuration file written in tsv format could look like the following table( with spaces replacing tabs ):
```text
deps
package lib value
name version authors keyword macro name Version Path
tsv 0.1.0 oooutlk tsv X serde 1.0
tab trees ~/trees
table
serde```
See [serialization example](https://github.com/oooutlk/tsv/blob/master/src/ser.rs#L546)
and [deserialization example](https://github.com/oooutlk/tsv/blob/master/src/de.rs#L804).