Spec-Zone.ru › Nushell

update cells for filters

Update the table cells.

Signature

> update cells {flags} (closure)

Flags

  • --columns, -c {list<any>}: List of columns to update.

Parameters

  • closure: The closure to run an update for each cell.

Input/output types:

input output
table table
record record

Examples

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 │             │             │
╰─────┴──────────────┴──────────────┴──────────────┴──────────────┴──────────────┴─────────────┴─────────────╯

Update each value in a record.

> {a: 1, b: 2, c: 3} | update cells { $in + 10 }
╭───┬────╮
│ a │ 11 │
│ b │ 12 │
│ c │ 13 │
╰───┴────╯

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/update_cells.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API