W3cubDocs

/Nushell

compact for filters

Creates a table with non-empty rows.

Signature

> compact {flags} ...rest

Parameters

  • ...rest: the columns to compact from the table

Input/output types:

input output
list<any> list<any>
table table

Examples

Filter out all records where 'Hello' is null (returns nothing)

> [["Hello""World"]; [null3]] |compactHello
╭────────────╮
emptylist
╰────────────╯

Filter out all records where 'World' is null (Returns the table)

> [["Hello""World"]; [null3]] |compactWorld
╭───┬───────┬───────╮
# │ Hello │ World │
├───┼───────┼───────┤
03
╰───┴───────┴───────╯

Filter out all instances of nothing from a list (Returns [1,2])

> [1, null, 2] |compact
╭───┬───╮
01
12
╰───┴───╯

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