split column
for strings> split column {flags} (separator) ...rest
--collapse-empty, -c
: remove empty columns--regex, -r
: separator is a regular expressionseparator
: the character or string that denotes what separates columns...rest
: column names to give the new columnsinput | output |
---|---|
list<string> | table |
string | table |
Split a string into columns by the specified separator
>'a--b--c'|split column'--'
╭───┬─────────┬─────────┬─────────╮
│# │ column1 │ column2 │ column3 │
├───┼─────────┼─────────┼─────────┤
│0│a│b│c│
╰───┴─────────┴─────────┴─────────╯
Split a string into columns of char and remove the empty columns
>'abc'|split column-c''
╭───┬─────────┬─────────┬─────────╮
│# │ column1 │ column2 │ column3 │
├───┼─────────┼─────────┼─────────┤
│0│a│b│c│
╰───┴─────────┴─────────┴─────────╯
Split a list of strings into a table
> ['a-b''c-d'] |split column-
╭───┬─────────┬─────────╮
│# │ column1 │ column2 │
├───┼─────────┼─────────┤
│0│a│b│
│1│c│d│
╰───┴─────────┴─────────╯
Split a list of strings into a table, ignoring padding
> ['a - b''c - d'] |split column-r'\s*-\s*'
╭───┬─────────┬─────────╮
│# │ column1 │ column2 │
├───┼─────────┼─────────┤
│0│a│b│
│1│c│d│
╰───┴─────────┴─────────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/split_column.html