From 0845572878b27bf5ae96177352de056178d0c2a9 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Tue, 26 Nov 2019 20:47:34 +0100 Subject: [PATCH 1/3] Add documentation for histogram, split-column --- docs/commands/histogram.md | 172 ++++++++++++++++++++++++++++++++++ docs/commands/sort-by.md | 2 +- docs/commands/split-column.md | 72 ++++++++++++++ 3 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 docs/commands/histogram.md create mode 100644 docs/commands/split-column.md diff --git a/docs/commands/histogram.md b/docs/commands/histogram.md new file mode 100644 index 0000000000..b2f5f3be5b --- /dev/null +++ b/docs/commands/histogram.md @@ -0,0 +1,172 @@ +# histogram + +Creates a new table with a histogram based on the column name passed in. + +Syntax: `histogram ...args` + +### Parameters + +* ``: name of the column to graph by +* `args`: column name to give the histogram's frequency column + +## Examples + +Let's say we have this file `random_numers.csv` which contains 50 random numbers. + +**Note**: The input doesn't have to be numbers it works on strings too. Try it out. + +```shell +> open random_numbers.csv +━━━━┯━━━━━━━━━━━━━━━ + # │ random number +────┼─────────────── + 0 │ 87 + 1 │ 46 + 2 │ 39 + + ... + + 47 │ 94 + 48 │ 61 + 49 │ 67 +━━━━┷━━━━━━━━━━━━━━━ +``` + +If we now want to see how often the different numbers were generated, we can use the `histogram` function: + +```shell +> open random_numbers.csv | histogram "random number" +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ frecuency +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 14 │ ************************************************** + 2 │ 17 │ ************************* + 3 │ 22 │ ************************* + 4 │ 24 │ ************************* + 5 │ 28 │ ************************* + 6 │ 29 │ ************************* + 7 │ 31 │ ************************* + 8 │ 37 │ ************************* + 9 │ 38 │ ************************* + 10 │ 39 │ ************************* + 11 │ 45 │ ************************* + 12 │ 46 │ *************************************************************************** + 13 │ 49 │ ************************* + 14 │ 5 │ ************************* + 15 │ 51 │ *************************************************************************** + 16 │ 52 │ ************************* + 17 │ 55 │ ************************* + 18 │ 56 │ ************************************************** + 19 │ 60 │ ************************* + 20 │ 61 │ ************************************************** + 21 │ 64 │ ************************* + 22 │ 65 │ ************************* + 23 │ 67 │ ************************************************** + 24 │ 68 │ ************************* + 25 │ 73 │ ************************* + 26 │ 80 │ ************************************************** + 27 │ 82 │ ************************* + 28 │ 86 │ **************************************************************************************************** + 29 │ 87 │ ************************************************** + 30 │ 88 │ ************************* + 31 │ 89 │ ************************* + 32 │ 9 │ ************************* + 33 │ 92 │ ************************* + 34 │ 94 │ ************************* + 35 │ 96 │ ************************* + 36 │ 99 │ ************************* +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +We can also set the name of the second column or sort the table: + +```shell +> open random_numbers.csv | histogram "random number" probability +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ probability +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 14 │ ************************************************** + 2 │ 17 │ ************************* + 3 │ 22 │ ************************* + 4 │ 24 │ ************************* + 5 │ 28 │ ************************* + 6 │ 29 │ ************************* + 7 │ 31 │ ************************* + 8 │ 37 │ ************************* + 9 │ 38 │ ************************* + 10 │ 39 │ ************************* + 11 │ 45 │ ************************* + 12 │ 46 │ *************************************************************************** + 13 │ 49 │ ************************* + 14 │ 5 │ ************************* + 15 │ 51 │ *************************************************************************** + 16 │ 52 │ ************************* + 17 │ 55 │ ************************* + 18 │ 56 │ ************************************************** + 19 │ 60 │ ************************* + 20 │ 61 │ ************************************************** + 21 │ 64 │ ************************* + 22 │ 65 │ ************************* + 23 │ 67 │ ************************************************** + 24 │ 68 │ ************************* + 25 │ 73 │ ************************* + 26 │ 80 │ ************************************************** + 27 │ 82 │ ************************* + 28 │ 86 │ **************************************************************************************************** + 29 │ 87 │ ************************************************** + 30 │ 88 │ ************************* + 31 │ 89 │ ************************* + 32 │ 9 │ ************************* + 33 │ 92 │ ************************* + 34 │ 94 │ ************************* + 35 │ 96 │ ************************* + 36 │ 99 │ ************************* +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +```shell +> open random_numbers.csv | histogram "random number" probability | sort-by probability +━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random number │ probability +────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 10 │ ************************* + 1 │ 17 │ ************************* + 2 │ 22 │ ************************* + 3 │ 24 │ ************************* + 4 │ 28 │ ************************* + 5 │ 29 │ ************************* + 6 │ 31 │ ************************* + 7 │ 37 │ ************************* + 8 │ 38 │ ************************* + 9 │ 39 │ ************************* + 10 │ 45 │ ************************* + 11 │ 49 │ ************************* + 12 │ 5 │ ************************* + 13 │ 52 │ ************************* + 14 │ 55 │ ************************* + 15 │ 60 │ ************************* + 16 │ 64 │ ************************* + 17 │ 65 │ ************************* + 18 │ 68 │ ************************* + 19 │ 73 │ ************************* + 20 │ 82 │ ************************* + 21 │ 88 │ ************************* + 22 │ 89 │ ************************* + 23 │ 9 │ ************************* + 24 │ 92 │ ************************* + 25 │ 94 │ ************************* + 26 │ 96 │ ************************* + 27 │ 99 │ ************************* + 28 │ 14 │ ************************************************** + 29 │ 56 │ ************************************************** + 30 │ 61 │ ************************************************** + 31 │ 67 │ ************************************************** + 32 │ 80 │ ************************************************** + 33 │ 87 │ ************************************************** + 34 │ 46 │ *************************************************************************** + 35 │ 51 │ *************************************************************************** + 36 │ 86 │ **************************************************************************************************** +━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/sort-by.md b/docs/commands/sort-by.md index 1f0f3da9ed..3d75dec6d4 100644 --- a/docs/commands/sort-by.md +++ b/docs/commands/sort-by.md @@ -1,5 +1,5 @@ -# env +# sort-by The `sort-by` command sorts the table being displayed in the terminal by a chosen column(s). diff --git a/docs/commands/split-column.md b/docs/commands/split-column.md new file mode 100644 index 0000000000..7cb3712755 --- /dev/null +++ b/docs/commands/split-column.md @@ -0,0 +1,72 @@ +# split-column + +Split row contents across multiple columns via the separator. + +Syntax: `split-column ...args{flags}` + +### Parameters + +* ``: string that denotes what separates columns +* `args`: column names to give the new columns. If not specified they will be set to `Column1` `Column2` ... + +### Flags + + --collapse-empty + Removes empty columns + +## Examples + +If we have file structured like this: + +```shell +0.12643678160919541 | 0.6851851851851852 | 0.273972602739726 +0.28735632183908044 | 0.09259259259259259 | 0.6986301369863014 +0.8045977011494253 | 0.8148148148148148 | 0.7397260273972602 +0.28735632183908044 | 0.09259259259259259 | 0.547945205479452 +0.6896551724137931 | 0.7037037037037037 | 1.2465753424657535 +0.6896551724137931 | 0.8333333333333334 | 0.4657534246575342 +0.9080459770114943 | 1.3333333333333333 | 0.4931506849315068 +0.9310344827586207 | 1.1296296296296295 | 0.7123287671232876 +0.3448275862068966 | 0.018518518518518517 | 0.6575342465753424 +1.0459770114942528 | 1.0925925925925926 | 0.6164383561643836 +``` + +We can build a table from it using the `split-column` command + +```shell +> open coordinates.txt | lines | split-column " | " +━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━ + # │ Column1 │ Column2 │ Column3 +───┼─────────────────────┼──────────────────────┼──────────────────── + 0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726 + 1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014 + 2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602 + 3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452 + 4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535 + 5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342 + 6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068 + 7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876 + 8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424 + 9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836 +━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━ +``` + +And give names to the columns + +```shell +> open coordinates.txt | lines | split-column " | " x y z +━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━ + # │ x │ y │ z +───┼─────────────────────┼──────────────────────┼──────────────────── + 0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726 + 1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014 + 2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602 + 3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452 + 4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535 + 5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342 + 6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068 + 7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876 + 8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424 + 9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836 +━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From 5bdda06ca6606c9e04bbd0ce6d04695fc42b8f81 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Thu, 28 Nov 2019 19:32:31 +0100 Subject: [PATCH 2/3] update histogram, nth documentation --- docs/commands/histogram.md | 184 ++++++++++--------------------------- docs/commands/nth.md | 25 +++-- 2 files changed, 64 insertions(+), 145 deletions(-) diff --git a/docs/commands/histogram.md b/docs/commands/histogram.md index b2f5f3be5b..228c3b7a2c 100644 --- a/docs/commands/histogram.md +++ b/docs/commands/histogram.md @@ -17,156 +17,64 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers ```shell > open random_numbers.csv -━━━━┯━━━━━━━━━━━━━━━ - # │ random number -────┼─────────────── - 0 │ 87 - 1 │ 46 - 2 │ 39 - +open random_numbers2.csv +━━━━┯━━━━━━━━━━━━━━━━ + # │ random numbers +────┼──────────────── + 0 │ 0 + 1 │ 5 + 2 │ 5 ... - - 47 │ 94 - 48 │ 61 - 49 │ 67 -━━━━┷━━━━━━━━━━━━━━━ + 47 │ 0 + 48 │ 2 + 49 │ 4 +━━━━┷━━━━━━━━━━━━━━━━ ``` If we now want to see how often the different numbers were generated, we can use the `histogram` function: ```shell -> open random_numbers.csv | histogram "random number" -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ frecuency -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 14 │ ************************************************** - 2 │ 17 │ ************************* - 3 │ 22 │ ************************* - 4 │ 24 │ ************************* - 5 │ 28 │ ************************* - 6 │ 29 │ ************************* - 7 │ 31 │ ************************* - 8 │ 37 │ ************************* - 9 │ 38 │ ************************* - 10 │ 39 │ ************************* - 11 │ 45 │ ************************* - 12 │ 46 │ *************************************************************************** - 13 │ 49 │ ************************* - 14 │ 5 │ ************************* - 15 │ 51 │ *************************************************************************** - 16 │ 52 │ ************************* - 17 │ 55 │ ************************* - 18 │ 56 │ ************************************************** - 19 │ 60 │ ************************* - 20 │ 61 │ ************************************************** - 21 │ 64 │ ************************* - 22 │ 65 │ ************************* - 23 │ 67 │ ************************************************** - 24 │ 68 │ ************************* - 25 │ 73 │ ************************* - 26 │ 80 │ ************************************************** - 27 │ 82 │ ************************* - 28 │ 86 │ **************************************************************************************************** - 29 │ 87 │ ************************************************** - 30 │ 88 │ ************************* - 31 │ 89 │ ************************* - 32 │ 9 │ ************************* - 33 │ 92 │ ************************* - 34 │ 94 │ ************************* - 35 │ 96 │ ************************* - 36 │ 99 │ ************************* -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ frequency +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 0 │ **************************************************************************************************** + 1 │ 1 │ ****************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 4 │ ***************************************************** + 5 │ 5 │ ********************************************************************* +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` We can also set the name of the second column or sort the table: ```shell -> open random_numbers.csv | histogram "random number" probability -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ probability -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 14 │ ************************************************** - 2 │ 17 │ ************************* - 3 │ 22 │ ************************* - 4 │ 24 │ ************************* - 5 │ 28 │ ************************* - 6 │ 29 │ ************************* - 7 │ 31 │ ************************* - 8 │ 37 │ ************************* - 9 │ 38 │ ************************* - 10 │ 39 │ ************************* - 11 │ 45 │ ************************* - 12 │ 46 │ *************************************************************************** - 13 │ 49 │ ************************* - 14 │ 5 │ ************************* - 15 │ 51 │ *************************************************************************** - 16 │ 52 │ ************************* - 17 │ 55 │ ************************* - 18 │ 56 │ ************************************************** - 19 │ 60 │ ************************* - 20 │ 61 │ ************************************************** - 21 │ 64 │ ************************* - 22 │ 65 │ ************************* - 23 │ 67 │ ************************************************** - 24 │ 68 │ ************************* - 25 │ 73 │ ************************* - 26 │ 80 │ ************************************************** - 27 │ 82 │ ************************* - 28 │ 86 │ **************************************************************************************************** - 29 │ 87 │ ************************************************** - 30 │ 88 │ ************************* - 31 │ 89 │ ************************* - 32 │ 9 │ ************************* - 33 │ 92 │ ************************* - 34 │ 94 │ ************************* - 35 │ 96 │ ************************* - 36 │ 99 │ ************************* -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" probability +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ probability +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 0 │ **************************************************************************************************** + 1 │ 1 │ ****************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 4 │ ***************************************************** + 5 │ 5 │ ********************************************************************* +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ``` ```shell -> open random_numbers.csv | histogram "random number" probability | sort-by probability -━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - # │ random number │ probability -────┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── - 0 │ 10 │ ************************* - 1 │ 17 │ ************************* - 2 │ 22 │ ************************* - 3 │ 24 │ ************************* - 4 │ 28 │ ************************* - 5 │ 29 │ ************************* - 6 │ 31 │ ************************* - 7 │ 37 │ ************************* - 8 │ 38 │ ************************* - 9 │ 39 │ ************************* - 10 │ 45 │ ************************* - 11 │ 49 │ ************************* - 12 │ 5 │ ************************* - 13 │ 52 │ ************************* - 14 │ 55 │ ************************* - 15 │ 60 │ ************************* - 16 │ 64 │ ************************* - 17 │ 65 │ ************************* - 18 │ 68 │ ************************* - 19 │ 73 │ ************************* - 20 │ 82 │ ************************* - 21 │ 88 │ ************************* - 22 │ 89 │ ************************* - 23 │ 9 │ ************************* - 24 │ 92 │ ************************* - 25 │ 94 │ ************************* - 26 │ 96 │ ************************* - 27 │ 99 │ ************************* - 28 │ 14 │ ************************************************** - 29 │ 56 │ ************************************************** - 30 │ 61 │ ************************************************** - 31 │ 67 │ ************************************************** - 32 │ 80 │ ************************************************** - 33 │ 87 │ ************************************************** - 34 │ 46 │ *************************************************************************** - 35 │ 51 │ *************************************************************************** - 36 │ 86 │ **************************************************************************************************** -━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability +━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ random numbers │ probability +───┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 │ 1 │ ****************************** + 1 │ 4 │ ***************************************************** + 2 │ 2 │ ************************************************************* + 3 │ 3 │ ********************************************************************* + 4 │ 5 │ ********************************************************************* + 5 │ 0 │ **************************************************************************************************** +━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ``` \ No newline at end of file diff --git a/docs/commands/nth.md b/docs/commands/nth.md index 0c8ce57f0c..9daff43eef 100644 --- a/docs/commands/nth.md +++ b/docs/commands/nth.md @@ -3,10 +3,13 @@ This command returns the nth row of a table, starting from 0. If the number given is less than 0 or more than the number of rows, nothing is returned. -## Usage +### Usage ```shell -> [input-command] | nth [row-number] +> [input-command] | nth ...args ``` +### Parameters: +* `` the number of the row to return +* `args`: Optionally return more rows ## Examples ```shell @@ -21,11 +24,19 @@ If the number given is less than 0 or more than the number of rows, nothing is r ━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ > ls | nth 0 -━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ - name │ type │ readonly │ size │ accessed │ modified -────────────┼──────┼──────────┼────────┼───────────────┼─────────────── - Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago -━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ +━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ + # │ name │ type │ readonly │ size │ accessed │ modified +───┼────────────┼───────────┼──────────┼────────┼───────────────┼─────────────── + 0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago +━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ + +> ls | nth 0 2 +━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ + # │ name │ type │ readonly │ size │ accessed │ modified +───┼────────────┼───────────┼──────────┼────────┼───────────────┼─────────────── + 0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago + 2 │ .gitignore │ File │ │ 19 B │ 2 minutes ago │ 2 minutes ago +━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ > ls | nth 5 ``` \ No newline at end of file From c77059f891a8dbcb4a3d69402570d5f7dc14210c Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Thu, 28 Nov 2019 19:33:17 +0100 Subject: [PATCH 3/3] add documentation for from-json, from-yaml, history, split-row --- docs/commands/from-json.md | 33 +++++++++++++++++++++++++++++++++ docs/commands/from-yaml.md | 24 ++++++++++++++++++++++++ docs/commands/history.md | 17 +++++++++++++++++ docs/commands/split-row.md | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 docs/commands/from-json.md create mode 100644 docs/commands/from-yaml.md create mode 100644 docs/commands/history.md create mode 100644 docs/commands/split-row.md diff --git a/docs/commands/from-json.md b/docs/commands/from-json.md new file mode 100644 index 0000000000..bb07d880f7 --- /dev/null +++ b/docs/commands/from-json.md @@ -0,0 +1,33 @@ +# from-json + +Parse text as `.json` and create table. Use this when nushell cannot dertermine the input file extension. + +Syntax: `from-json {flags}` + +### Flags: + + --objects + treat each line as a separate value + + +## Examples + +```shell +> open command_from-json +[ + { + title: "from-json", + type: "command", + flags: true + } +] +``` + +```shell +> open command_from-json | from-json +━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━ + title │ type │ flags +───────────┼─────────┼─────── + from-json │ command │ Yes +━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md new file mode 100644 index 0000000000..1c81c7dc94 --- /dev/null +++ b/docs/commands/from-yaml.md @@ -0,0 +1,24 @@ +# from-yaml + +Parse text as `.yaml/.yml` and create table. + +Syntax: `from-yaml` + +## Examples + +```shell +> open command_from-yaml +title: from-yaml +type: command +flags: false +``` + +```shell +> open command_from-yaml | from-yaml +━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━ + title │ type │ flags +───────────┼─────────┼─────── + from-yaml │ command │ No +━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━ + +``` diff --git a/docs/commands/history.md b/docs/commands/history.md new file mode 100644 index 0000000000..095cfeff34 --- /dev/null +++ b/docs/commands/history.md @@ -0,0 +1,17 @@ +# history + +Displays the last 100 commands. + +## Example + +```shell +> history +━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ +────┼─────────────────────────────────────────────────────────────────────────── + ... + 97 │ ls + 98 │ ls | where accessed < 1d + 99 │ cd +━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/split-row.md b/docs/commands/split-row.md new file mode 100644 index 0000000000..50744fcc60 --- /dev/null +++ b/docs/commands/split-row.md @@ -0,0 +1,34 @@ +# split-row + +Split row contents over multiple rows via the separator. + +Syntax: `split-row ` + +### Parameters: +* `` the character that denotes what separates rows + +## Examples + +We can build a table from a file that looks like this + +```shell +> open table.txt +4, 0, 2, 0, 7, 8 + +``` + +using the `split-row` command. + +```shell +open table.txt | split-row ", " +━━━┯━━━━━━━━━ + # │ +───┼───────── + 0 │ 4 + 1 │ 0 + 2 │ 2 + 3 │ 0 + 4 │ 7 + 5 │ 8 +━━━┷━━━━━━━━━ +``` \ No newline at end of file