Added CSV roundtrip

This commit is contained in:
Mike Farah
2022-08-01 10:05:26 +10:00
parent cb0bae128f
commit 9628aaf8c5
13 changed files with 424 additions and 105 deletions
+28 -1
View File
@@ -1,3 +1,30 @@
# CSV
Encode (arrays of arrays) data structures to CSV or TSV, Decode CSV, TSV into an array of objects.
Encode/Decode to CSV or TSV.
## Encode
Currently supports arrays of homogenous flat objects, that is: no nesting and it assumes the _first_ object has all the keys required:
```yaml
- name: Bobo
type: dog
- name: Fifi
type: cat
```
As well as arrays of arrays of scalars (strings/numbers/booleans):
```yaml
- [Bobo, dog]
- [Fifi, cat]
```
## Decode
Decode assumes the first CSV/TSV row is the header row, and all rows beneath are the entries.
The data will be coded into an array of objects, using the header rows as keys.
```csv
name,type
Bobo,dog
Fifi,cat
```