From 2b9b71f62d86be7595ea4244890fae644aa1c9bc Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sun, 28 Mar 2021 07:23:37 -0500 Subject: [PATCH] added get-column --- stdlib_candidate/get-column.nu | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/stdlib_candidate/get-column.nu b/stdlib_candidate/get-column.nu index 9f5def4..988e086 100644 --- a/stdlib_candidate/get-column.nu +++ b/stdlib_candidate/get-column.nu @@ -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 -} \ No newline at end of file + # 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 \ No newline at end of file