-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table and list helper commands #967
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are useful and cool but I'm just not sure "ranges" works because nushell ranges are 0..2 and 0..2..10. Maybe if someone uses a range it'll still work?
It works with ranges - At least The I went with The only thing it can't do is an infinity-range, of course (and I might be able to eke that out), but all of the following work: # Same as | first 3
ls | select ranges ..2
# => ╭───┬────────────────────┬──────┬──────────┬──────────────╮
# => │ # │ name │ type │ size │ modified │
# => ├───┼────────────────────┼──────┼──────────┼──────────────┤
# => │ 0 │ CITATION.cff │ file │ 812 B │ 3 months ago │
# => │ 1 │ CODE_OF_CONDUCT.md │ file │ 3.4 KiB │ 7 months ago │
# => │ 2 │ CONTRIBUTING.md │ file │ 11.0 KiB │ 3 months ago │
# => ╰───┴────────────────────┴──────┴──────────┴──────────────╯
# Every other row between 0 and 8 inclusive
ls | select ranges 0..2..8
# => ╭───┬─────────────────┬──────┬──────────┬──────────────╮
# => │ # │ name │ type │ size │ modified │
# => ├───┼─────────────────┼──────┼──────────┼──────────────┤
# => │ 0 │ CITATION.cff │ file │ 812 B │ 3 months ago │
# => │ 2 │ CONTRIBUTING.md │ file │ 11.0 KiB │ 3 months ago │
# => │ 4 │ Cargo.toml │ file │ 9.0 KiB │ 8 hours ago │
# => │ 6 │ LICENSE │ file │ 1.1 KiB │ 7 months ago │
# => │ 8 │ SECURITY.md │ file │ 2.6 KiB │ 2 months ago │
# => ╰───┴─────────────────┴──────┴──────────┴──────────────╯
# Every other column from the first three trows
ls -l | select column-ranges 0..2..100 | select ranges ..2
# => ╭───┬────────────────────┬────────┬───────────┬────────┬───────┬──────────────┬──────────────╮
# => │ # │ name │ target │ mode │ inode │ group │ created │ modified │
# => ├───┼────────────────────┼────────┼───────────┼────────┼───────┼──────────────┼──────────────┤
# => │ 0 │ CITATION.cff │ │ rw-r--r-- │ 393244 │ ntd │ 3 months ago │ 3 months ago │
# => │ 1 │ CODE_OF_CONDUCT.md │ │ rw-r--r-- │ 430741 │ ntd │ 7 months ago │ 7 months ago │
# => │ 2 │ CONTRIBUTING.md │ │ rw-r--r-- │ 371737 │ ntd │ 3 months ago │ 3 months ago │
# => ╰───┴────────────────────┴────────┴───────────┴────────┴───────┴──────────────┴──────────────╯
# Every third column from rows 4, 7, 9, and 10
ls -l | select column-ranges 0..3..100 | select ranges 4 7 9..10
# => ╭────┬────────────┬──────────┬────────┬──────────┬──────────────╮
# => │ # │ name │ readonly │ inode │ size │ modified │
# => ├────┼────────────┼──────────┼────────┼──────────┼──────────────┤
# => │ 4 │ Cargo.toml │ false │ 77221 │ 9.0 KiB │ 8 hours ago │
# => │ 7 │ README.md │ false │ 371008 │ 12.0 KiB │ 3 months ago │
# => │ 9 │ assets │ false │ 430748 │ 4.0 KiB │ 7 months ago │
# => │ 10 │ benches │ false │ 430753 │ 4.0 KiB │ 19 hours ago │
# => ╰────┴────────────┴──────────┴────────┴──────────┴──────────────╯ |
gotcha, as long as it works, it's probably fine. do you want to wait for tests or land this? |
Ah, I'm going to hate myself for saying this, but hold off. It will push me to get the tests written sooner ;-) |
Tests added. Also fixed the |
Good work! Thanks!! |
From nushell/nushell#13887, this adds: ```nu into list select ranges select column-ranges reject ranges reject column-ranges row-indices col-indices ``` Note that these replace the former `get-row` and `get-col` commands that were in the library. They have the same functionality and can accept any combination of: * One or more row or column indices * One or more row or column ranges
From nushell/nushell#13887, this adds:
Note that these replace the former
get-row
andget-col
commands that were in the library. They have the same functionality and can accept any combination of: