1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Merge pull request #34 from fdncred/main

added get-column.nu
This commit is contained in:
Darren Schroeder 2021-03-28 07:24:49 -05:00 committed by GitHub
commit 81ad102c8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,26 @@
# This is a wrapper to get a row
# Documentation for get-col
# Written on 2021-03-28 06:58:50 by andras_io on discord
def get-col [
col_name:any # A 0 indexed row
col_index:int # A 0 indexed col_index
] {
get $col_name
}
# meant to be used like `ls | get-col 1`
# ls | select $(ls | get | nth 2)
each {
echo $it | select $(echo $it | get | nth $col_index)
}
}
# Documentation for get-col2
# Written on 2021-03-28 07:00:24 by johng on discord
def get-column [
col_index:int # A 0 indexed col_index
] {
# meant to be used like `ls | get-column 1`
pivot | nth $col_index | pivot | get Column1 | skip
}
# another working example is
# ls | keep 2 | drop column 3