Home Explore Blog CI



nushell

commands/docs/headers.md
3fd872acff71534a176350d7ad2090683aa0927533536e6b000000030000053e
---
title: headers
categories: |
  filters
version: 0.104.0
filters: |
  Use the first row of the table as column names.
usage: |
  Use the first row of the table as column names.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `headers` for [filters](/commands/categories/filters.md)

<div class='command-title'>Use the first row of the table as column names.</div>

## Signature

```> headers {flags} ```


## Input/output types:

| input | output |
| ----- | ------ |
| table | table  |
## Examples

Sets the column names for a table created by `split column`
```nu
> "a b c|1 2 3" | split row "|" | split column " " | headers
╭───┬───┬───┬───╮
│ # │ a │ b │ c │
├───┼───┼───┼───┤
│ 0 │ 1 │ 2 │ 3 │
╰───┴───┴───┴───╯

```

Columns which don't have data in their first row are removed
```nu
> "a b c|1 2 3|1 2 3 4" | split row "|" | split column " " | headers
╭───┬───┬───┬───╮
│ # │ a │ b │ c │
├───┼───┼───┼───┤
│ 0 │ 1 │ 2 │ 3 │
│ 1 │ 1 │ 2 │ 3 │
╰───┴───┴───┴───╯

```

Chunks
aac07b30 (1st chunk of `commands/docs/headers.md`)
Title: headers command in Nushell
Summary
The `headers` command in Nushell takes a table as input and uses the first row of the table to set the column names. Columns without data in the first row are removed. It's often used in conjunction with commands like `split column` to structure data.