Commit 0501b2e6 authored by Ian Dennis Miller's avatar Ian Dennis Miller

Update csv-functions.sh

parent 0152ae76
alias csv.collapse_lines='perl -pe "s/\\\\\n/ /" -'
alias csv.remove_quotes='sed "s/\"//g"'
alias csv.collapse='perl -pe "s/\\\\\n/ /" -'
alias csv.unquote='sed "s/\"//g"'
alias csv.split='sed -e "s/,/\\n/g"'
function csv.select_index() { awk -F, "{print \$$1}" }
function csv.index() { awk -F, "{print \$$1}" }
function csv.limit() { head -n$1 }
function csv.cat() { cat $1 | csv.collapse_lines | csv.remove_quotes }
function csv.names() { csv.cat $1 | csv.limit 1 | csv.split }
function csv.sum() { awk '{s+=$1} END {printf "%.0f", s}' - }
function csv.cat() { cat $1 | csv.collapse }
function csv.names() { csv.cat $1 | csv.limit 1 | csv.unquote | csv.split }
function csv.sum() { awk '{ s += $1 } END { printf "%.8f\n", s }' - }
function csv.mean() { awk '{ s += $1; n++ } END { printf "%.8f\n", s/n }' - }
function csv.count() { wc -l - | awk '{ print $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