W3cubDocs

/Nushell

columns for filters

Given a record or table, produce a list of its columns' names.

Signature

> columns {flags}

Input/output types:

input output
record list<string>
table list<string>

Examples

Get the columns from the record

> { acronym:PWD, meaning:'Print Working Directory' } |columns
╭───┬─────────╮
0acronym
1meaning
╰───┴─────────╯

Get the columns from the table

> [[name,age,grade]; [bill,20,a]] |columns
╭───┬───────╮
0name
1age
2grade
╰───┴───────╯

Get the first column from the table

> [[name,age,grade]; [bill,20,a]] |columns|first

Get the second column from the table

> [[name,age,grade]; [bill,20,a]] |columns|select1

Notes

This is a counterpart to values, which produces a list of columns' values.

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