compact for filters

Creates a table with non-empty rows.

Signature

> compact {flags} ...rest

Flags

  • --empty, -e: also compact empty items like "", {}, and []

Parameters

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

Input/output types:

inputoutput
list<any>list<any>

Examples

Filter out all records where 'Hello' is null

> [["Hello" "World"]; [null 3]] | compact Hello
╭────────────╮
 empty list 
╰────────────╯

Filter out all records where 'World' is null

> [["Hello" "World"]; [null 3]] | compact World
╭───┬───────┬───────╮
 # │ Hello │ World │
├───┼───────┼───────┤
 0             3 
╰───┴───────┴───────╯

Filter out all instances of null from a list

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

Filter out all instances of null and empty items from a list

> [1, null, 2, "", 3, [], 4, {}, 5] | compact --empty
╭───┬───╮
 0  1 
 1  2 
 2  3 
 3  4 
 4  5 
╰───┴───╯