mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 09:29:14 +01:00
5d59234f8d
Very often we need to work with tables (say extracted from unstructured data or some kind of final report, timeseries, and the like). It's inevitable we will be having columns that we can't know beforehand what their names will be, or how many. Also, we may end up with certain cells having values we may want to remove as we explore. Here, `update cells` fundamentally goes over every cell in the table coming in and updates the cell's contents with the output of the block passed. Basic example here: ``` > [ [ ty1, t2, ty]; [ 1, a, $nothing] [(wrap), (0..<10), 1Mb] [ 1s, ({}), 1000000] [ $true, $false, ([[]])] ] | update cells { describe } ───┬───────────────────────┬───────────────────────────┬────────── # │ ty1 │ t2 │ ty ───┼───────────────────────┼───────────────────────────┼────────── 0 │ integer │ string │ nothing 1 │ row Column(table of ) │ range[[integer, integer)] │ filesize 2 │ string │ nothing │ integer 3 │ boolean │ boolean │ table of ───┴───────────────────────┴───────────────────────────┴────────── ``` and another one (in the examples) for cases, say we have a timeseries table generated and we want to remove the zeros and have empty strings and save it out to something like CSV. ``` > [ [2021-04-16, 2021-06-10, 2021-09-18, 2021-10-15, 2021-11-16, 2021-11-17, 2021-11-18]; [ 37, 0, 0, 0, 37, 0, 0] ] | update cells {|value| i if ($value | into int) == 0 { "" } { $value } } ───┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬──────────── # │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 ───┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼──────────── 0 │ 37 │ │ │ │ 37 │ │ ───┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴──────────── ``` |
||
---|---|---|
.. | ||
assets | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
README.md |
nu-command
The Nu command crate contains the full set of internal commands, that is, the commands that can be form the set of built-in commands in a Nushell engine.
The default set of commands that Nushell ships with can be found in the default context.
The commands themselves live in the commands module.