Skip to content

feat(from xlsx): add support for header row - #18189

Merged
fdncred merged 1 commit into
nushell:mainfrom
pyz4:feat-xlsx-header
May 13, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
pyz4:feat-xlsx-header

Conversation

@pyz4

@pyz4 pyz4 commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds the optional flag --header-row to from xlsx to specify which row should be read in as the column names . By default, the first non-empty row is read in as the header. Specify --header null for legacy behavior (no headers are read). See example:

# first non-empty row
open test.xlsx --raw | from xlsx

# specify header row by index
open test.xlsx --raw | from xlsx --header-row 1

# legacy behavior (no headers)
open test.xlsx --raw | from xlsx --header-row null

User-facing changes (Release notes)

from xlsx now supports --header-row for specifying the 0-indexed index of the row from which to read column names. Default is the first non-empty row, which is a breaking change. Specify --header-row null for legacy behavior (i.e., no header).

Additional notes

fixes #16114

.named(
"header-row",
SyntaxShape::OneOf(vec![SyntaxShape::Int, SyntaxShape::Nothing]),
"Specify row index to designate the header (default first non-empty row) or null for no header",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call it "Excel" row index so people (like me) aren't confused by 0-indexed or 1-indexed, just excel indexed?

Suggested change
"Specify row index to designate the header (default first non-empty row) or null for no header",
"Specify Excel row index to designate the header (default first non-empty row) or null for no header",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is 0-indexed. I'll clarify that in the text.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, that's a bit confusing since Excel is 1 indexed.

@pyz4
pyz4 force-pushed the feat-xlsx-header branch 2 times, most recently from ef955a4 to 379a204 Compare May 13, 2026 14:08
@pyz4
pyz4 force-pushed the feat-xlsx-header branch from 379a204 to c7c3bb8 Compare May 13, 2026 14:16
@pyz4

pyz4 commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@fdncred The PR should be good to go now. It now sets default names for columns that are missing headers when other columns have headers.

@fdncred

fdncred commented May 13, 2026

Copy link
Copy Markdown
Contributor

We just need a to xlsx now. Thanks!

@fdncred
fdncred merged commit d98c008 into nushell:main May 13, 2026
17 checks passed
@github-actions github-actions Bot added this to the v0.113.0 milestone May 13, 2026
@weirdan

weirdan commented May 13, 2026

Copy link
Copy Markdown
Contributor

Am I right assuming that open test.xlsx behaviour also changes with this PR?

@fdncred since the defaults change, this probably needs to be marked as a breaking change.

@fdncred

fdncred commented May 13, 2026

Copy link
Copy Markdown
Contributor

ya, it changes. I just tested it out. I think it's a change for the better, but it is a breaking change. Thanks @weirdan.

Before

❯ open ~/Desktop/cmds_by_crates_and_tags_long.xlsx | get cmds_by_crates_and_tags_long | first 10
╭─#─┬───────column0────────┬─column1─┬─column2─┬─column3─┬─column4─┬─column5─┬─column6─┬─column7─┬─column8─╮
│ 0 │ name                 │ crate   │ tag     │ major   │ minor   │ patch   │ major1  │ minor1  │ patch1  │
│ 1 │ <whitespace? eof>    │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 2 │ BackoffColoringMode  │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 3 │ SimplestExpression   │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 4 │ StringShape          │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 5 │ any block            │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 6 │ any expression       │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 7 │ any expression start │ crates  │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 8 │ append               │ src     │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
│ 9 │ autoview             │ src     │ 0.10.0  │ 0       │ 10      │ 0       │ 0       │ 10      │ 0       │
╰─#─┴───────column0────────┴─column1─┴─column2─┴─column3─┴─column4─┴─column5─┴─column6─┴─column7─┴─column8─╯

After this PR

❯ open ~/Desktop/cmds_by_crates_and_tags_long.xlsx | get cmds_by_crates_and_tags_long | first 10
╭─#─┬─────────name─────────┬─crate──┬──tag───┬─major─┬─minor─┬─patch─┬─major1─┬─minor1─┬─patch1─╮
│ 0 │ <whitespace? eof>    │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 1 │ BackoffColoringMode  │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 2 │ SimplestExpression   │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 3 │ StringShape          │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 4 │ any block            │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 5 │ any expression       │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 6 │ any expression start │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 7 │ append               │ src    │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 8 │ autoview             │ src    │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
│ 9 │ bare expression      │ crates │ 0.10.0 │ 0     │ 10    │ 0     │ 0      │ 10     │ 0      │
╰─#─┴─────────name─────────┴─crate──┴──tag───┴─major─┴─minor─┴─patch─┴─major1─┴─minor1─┴─patch1─╯

@fdncred fdncred added notes:breaking-changes Noted in Breaking Changes section notes:ready Indicates Ready for Release notes labels May 13, 2026
@pyz4
pyz4 deleted the feat-xlsx-header branch May 13, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:breaking-changes Noted in Breaking Changes section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align from xlsx closer to from tsv when handling headers.

3 participants