Repository navigation
"csvtk --show-row-number concat" does not print row number column. #360
Description
Activity
Only a few commands support that flag (see the appendix below). And other commands needing the row number can be piped to one of these commands, like
$ printf "a,b\n1,2\n" | csvtk concat - <(printf "a,b\n10,20\n") | csvtk cut -f 1- -Z row,a,b 1,1,2 2,10,20But I've enabled
concatto support it now.$ printf "a,b\n1,2\n" | csvtk concat - <(printf "a,b\n10,20\n") -Z row,a,b 1,1,2 2,10,20 $ printf "a,b\n1,2\n" | csvtk concat - <(printf "a,b\n10,20\n") -Z -H 1,a,b 2,1,2 3,a,b 4,10,20 $ printf "a,b\n1,2\n" | csvtk concat - <(printf "a,b\n10,20\n") -U 1,2 10,20 $ printf "a,b\n1,2\n" | csvtk concat - <(printf "a,b\n10,20\n") -Z -U 1,1,2 2,10,20I also make
concataccept one input file now.$ printf "a,b\n1,2\n" | csvtk concat -Z row,a,b 1,1,2appendix:
$ rg config.ShowRowNumber csvtk/cmd/csv2xlsx.go 91: ShowRowNumber: config.ShowRowNumber, csvtk/cmd/sample.go 96: ShowRowNumber: printLineNumber || config.ShowRowNumber, csvtk/cmd/pretty.go 210: ShowRowNumber: config.ShowRowNumber, 286: if config.ShowRowNumber { 295: if config.ShowRowNumber { 303: if config.ShowRowNumber { 318: if config.ShowRowNumber { 355: if config.ShowRowNumber { 373: if config.ShowRowNumber { csvtk/cmd/cut.go 126: ShowRowNumber: config.ShowRowNumber, csvtk/cmd/csv2tab.go 68: ShowRowNumber: config.ShowRowNumber, csvtk/cmd/filter2.go 193: showRowNumber := printLineNumber || config.ShowRowNumber csvtk/cmd/head.go 71: printLineNumber := config.ShowRowNumber csvtk/cmd/del-quotes.go 76: ShowRowNumber: config.ShowRowNumber, csvtk/cmd/filter.go 97: showRowNumber := printLineNumber || config.ShowRowNumber csvtk/cmd/tab2csv.go 69: ShowRowNumber: config.ShowRowNumber, csvtk/cmd/grep.go 82: printLineNumber := getFlagBool(cmd, "line-number") || config.ShowRowNumberThank you for this change. This will resolve the inconsistency between
csvtk concat --show-row-numberand its help documentation (--help) which specifies that--show-row-numberis a global flag which applies to all commands.In csvtk v0.37.0 and earlier, does
csvtk concatrequire at least two input files? Like in my example above, I've often used that command with only one input source, usually standard input.It accepts one file before but needs to load all data in memory and then dump to output. Today's change make it more menory-effcient.
Reacted by Derek Mahar
In csvtk v0.37.0,
csvtk --show-row-number concatdoes not print the row number column:By comparison,
csvtk --show-row-number cutdoes print the row number column: