Auto-generate markdown command docs (#4451)

* Finish updating

* a couple improvements

* Update renames

* cleanup examples
This commit is contained in:
JT
2022-02-13 21:22:51 -05:00
committed by GitHub
parent 06f5affc0b
commit 8c0a2d3c15
478 changed files with 7676 additions and 8045 deletions

View File

@ -1,105 +1,33 @@
# append
---
title: append
layout: command
version: 0.59.0
---
Append a row to the table.
## Signature
```> append (row)```
## Parameters
- `row`: the row to append
## Examples
Given the following text file `cities.txt` containing cities:
Append one Int item
```shell
Canberra
London
Nairobi
Washington
> [0,1,2,3] | append 4
```
And getting back a Nu table:
Append three Int items
```shell
> open cities.txt | lines
───┬────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
> [0,1] | append [2,3,4]
```
Add the city named `Beijing` like so:
Append Ints and Strings
```shell
> open cities.txt | lines | append Beijing
───┬────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Beijing
───┴────────────
> [0,1] | append [2,nu,4,shell]
```
It's not possible to add multiple rows at once, so you'll need to use `append` multiple times:
```shell
> open cities.txt | lines | append Beijing | append "Buenos Aires"
───┬──────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Beijing
5 │ Buenos Aires
───┴──────────────
```
So far we have been working with a table without a column, which leaves us with plain rows. Let's `wrap` the plain rows into a column called `city` and save it as a json file called `cities.json`:
Before we save, let's check how it looks after wrapping:
```shell
open cities.txt | lines | wrap city
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
```
And save:
`> open cities.txt | lines | wrap city | save cities.json`
Since we will be working with rows that have a column, appending like before won't quite give us back what we want:
```shell
> open cities.json | append Guayaquil
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
───┬───────────
4 │ Guayaquil
───┴───────────
```
We append a row literal directly:
```shell
> open cities.json | append [[city]; [Guayaquil]]
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Guayaquil
───┴────────────
```