You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is being marked stale because it has been open for 90 days without activity. If you feel that this is in error, please comment below and we will keep it marked as active.
How about creating an empty table? Is this possible?
I was in the same situation. If you're not used to working functionally most of the time, this is a sensible starting place. Then you mutate it by adding in your column headers, and then add in values.
Here's an effort to "tile the space" to look for gaps in our current ability to work with tables.
Working with columns
Capability Nu Support
Filter to subset of columns select
Filter to a column by number MISSING
...
...
Could a roundup like this be added to the documentation? This is really nice as a rapid index of what command I need to look for for a given job - more so than the more detailed pages here or here say, and this reads better to me (what I want to do is on the left; the command I need is on the right, and there may be a many-1 relationship between what I want and the command) than e.g. the listings of subcommands for strings here - not that the latter isn't useful as a reference in its own right. But this is excellent for trying to find what I need to type in when I don't know the name but I know what I need to do. Some indentation into a tree perhaps would then allow grouping related things I need to do (e.g. the retrieve a row ... can be grouped together)
Here's one way to create a table in a mutable fashion.
muttable= [] # A table is a list of records. So, let's start with an empty list.letrec1= {col:1} # A simple record with col as the key and 1 as the valueletrec2= {col:2} # Another record, note the same key$table# it's currently empty$table= ($table|append$rec1|append$rec2) # take $table and assign it $table while appending the 2 records$table╭#┬col╮│0│1││1│2│╰─┴───╯
Okay, so just an empty list. Thanks. I assumed it would be something like that, but wasn't sure. At that point I stepped back and realised I could probably do it with a map instead.
I also wasn't aware it was possible to use a "bare" assignment like that - I have done $record.field = value before, but possibly not $record = value. Would using let table = (...) then introduce an immutable variable that shadows the original one, same as it does normally?
It seems like the tables at the top of this post are out of date. There's a few commands that have either been renamed or removed, and I'm not sure of all of them.
Agreed that the OP could be updated. But I also like seeing things like "here are the table commands", "here are the record commands", "here are the list commands", etc.
I don't understand the use case. What's the point of an empty table?
To have a sort of option type so that data can be handled in a uniform way? Let's say there are no records and I still want to output table header (and possibly some indication that the table is empty):
$ [[name age]; [Sid 17]] | drop 1
# name age
────────────────
Not possible, since the table without records effectively becomes a list. The solution I came up with looks clumsy:
mut table = [[name age]; [Sid 17]]
let header = ($table | table | lines | drop ($table | length) | to text)
$table = $table | drop 1
if ($table | is-empty) {
print -n $header
print $'(ansi d)empty table(ansi reset)'
} else {
$table
}
This list is from 2019 and doesn't match the current command set anymore (edit, embed, nth, pivot and count are gone or renamed).
As shown above most of the rows marked as missing are one-liners by now.
So i think it doesn't track a gap anymore and i'm closing it.
The discussion about empty tables continues in #19320.
Activity
github-actions commentedon Jun 24, 2021
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
waldyrious commentedon Jul 4, 2021
This definitely doesn't look like an issue that should be closed for lack of updates. (Just commenting in case stale-bot is about to close it.)
github-actions commentedon Oct 6, 2021
This issue is being marked stale because it has been open for 90 days without activity. If you feel that this is in error, please comment below and we will keep it marked as active.
hustcer commentedon Oct 6, 2021
No stale
fdncred commentedon Feb 18, 2022
@jntrnr this looks good for some documentation after it's updated for 0.59. :)
sophiajt commentedon Aug 9, 2023
Keeping this open as the missing ones are still missing. It would be great to fix these for 1.0.
cbr9 commentedon Sep 30, 2023
How about creating an empty table? Is this possible?
fdncred commentedon Sep 30, 2023
I don't understand the use case. What's the point of an empty table?
cbr9 commentedon Sep 30, 2023
Actually, I was juggling with a problem but I found the solution without the need for empty tables (still trying to learn nushell)
Release notes for `0.80` (nushell#890)
stellarpower commentedon Oct 28, 2023
I was in the same situation. If you're not used to working functionally most of the time, this is a sensible starting place. Then you mutate it by adding in your column headers, and then add in values.
stellarpower commentedon Oct 28, 2023
Could a roundup like this be added to the documentation? This is really nice as a rapid index of what command I need to look for for a given job - more so than the more detailed pages here or here say, and this reads better to me (what I want to do is on the left; the command I need is on the right, and there may be a many-1 relationship between what I want and the command) than e.g. the listings of subcommands for strings here - not that the latter isn't useful as a reference in its own right. But this is excellent for trying to find what I need to type in when I don't know the name but I know what I need to do. Some indentation into a tree perhaps would then allow grouping related things I need to do (e.g. the
retrieve a row ...can be grouped together)fdncred commentedon Oct 28, 2023
Here's one way to create a table in a mutable fashion.
stellarpower commentedon Oct 28, 2023
Okay, so just an empty list. Thanks. I assumed it would be something like that, but wasn't sure. At that point I stepped back and realised I could probably do it with a map instead.
I also wasn't aware it was possible to use a "bare" assignment like that - I have done
$record.field = valuebefore, but possibly not$record = value. Would usinglet table = (...)then introduce an immutable variable that shadows the original one, same as it does normally?fdncred commentedon Oct 29, 2023
letdisallows mutability. You'd have to domut tablestellarpower commentedon Oct 29, 2023
Right, but what I mean is that here, this is shadowing the original variable right? Whereas using an equals sign is just mutating it.
fdncred commentedon Oct 29, 2023
yes, that's shadowing.
Zoybean commentedon Jan 22, 2024
It seems like the tables at the top of this post are out of date. There's a few commands that have either been renamed or removed, and I'm not sure of all of them.
Working with columns
editupdate?embedWorking with rows
nth --skipdrop nthnthnth <set of rows>Whole table
pivottransposecountlengthcount --columnConverting strings to tables
read,split columnparse?,split columnNotTheDr01ds commentedon Sep 1, 2024
Some of the "Missing" items can now be done easily enough that I don't know that there's a need for a dedicated command.
Filtering to a column by number
Filtering to a range of columns
Filtering by column conditions
Not 100% sure what is meant there, but I think a
transposewould work?Add a row at location
Can be done with spreading:
Replace a row
updatehandles this:fdncred commentedon Sep 1, 2024
Agreed that the OP could be updated. But I also like seeing things like "here are the table commands", "here are the record commands", "here are the list commands", etc.
youk commentedon Aug 27, 2025
To have a sort of option type so that data can be handled in a uniform way? Let's say there are no records and I still want to output table header (and possibly some indication that the table is empty):
Not possible, since the table without records effectively becomes a list. The solution I came up with looks clumsy:
Now let's move on to something more prosaic:
This is not what sane programming is about.
kronberger-droid commentedon Nov 13, 2026
This list is from 2019 and doesn't match the current command set anymore (
edit,embed,nth,pivotandcountare gone or renamed).As shown above most of the rows marked as missing are one-liners by now.
So i think it doesn't track a gap anymore and i'm closing it.
The discussion about empty tables continues in #19320.