Commit 74faa4fe authored by Ian Dennis Miller's avatar Ian Dennis Miller

Update csv-functions.sh

parent 12343ebb
......@@ -12,8 +12,11 @@ alias csv.unquote='sed "s/\"//g"'
# split a comma-delimited row onto separate lines
alias csv.split='sed -e "s/,/\\n/g"'
# produce awk expression suitable for selecting the requested columns
csv.awk_select_column() { awk 'BEGIN {for (i=1; i < ARGC; i++) printf "$" ARGV[i] ", "}' $@ | rev | cut -c 3- | rev }
# select a single column from a CSV by its index, starting at 1
csv.select_column() { awk -F, "{print \$$1}" }
csv.select_column() { awk -F, "BEGIN{OFS = \",\"} { print `csv.awk_select_column $@` }" }
# limit number of rows returned
csv.limit() { head -n $1 }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment