Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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:

inputoutput
tabletable

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