update cells
for filters> update cells {flags} (closure)
--columns, -c {table}
: list of columns to updateclosure
: the closure to run an update for each cellinput | output |
---|---|
table | table |
Update the zero value cells to empty strings.
> [
["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|
if$value==0 {
""
} else {
$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│││
╰──────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────┴──────────────┴──────────────╯
Update the zero value cells to empty strings in 2 last columns.
> [
["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-c ["2021-11-18", "2021-11-17"] { |value|
if$value==0 {
""
} else {
$value
}
}
╭──────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────┬──────────────┬──────────────╮
│# │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 │
├──────┼───────────────┼───────────────┼───────────────┼───────────────┼──────────────┼──────────────┼──────────────┤
│0│37│0│0│0│37│││
╰──────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────┴──────────────┴──────────────╯
Tips: Command update cells
was not included in the official binaries by default, you have to build it with --features=extra
flag
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/update_cells.html