Commit 56aceb54 authored by Ian Dennis Miller's avatar Ian Dennis Miller

Update csv-functions.sh

parent 74faa4fe
......@@ -3,6 +3,10 @@
# Perform streaming operations with CSV files.
# When files are too large to fit into memory, streaming might be the only alternative.
PROFILE="$HOME/.profile"
CSV_SRC="$HOME/.csv-functions.sh"
CSV_URL='https://projects.sisrlab.com/idm/dataset-guide/raw/master/csv-functions.sh?inline=false'
# collapse fields containing newlines
alias csv.collapse='perl -pe "s/\\\\\n/ /" -'
......@@ -33,8 +37,11 @@ csv.count() { wc -l - | awk '{ print $1 }' }
# cat a CSV file
csv.cat() { cat $1 | csv.collapse }
# print column names, each on a separate line
# For a CSV with a header row, print column names, each on a separate line
csv.names() { csv.cat $1 | csv.limit 1 | csv.unquote | csv.split }
# built-in updater
csv.update() { wget -O ~/.csv-functions.sh 'https://projects.sisrlab.com/idm/dataset-guide/raw/master/csv-functions.sh?inline=false'; source ~/.csv-functions.sh }
csv.update() { wget -O $CSV_SRC $CSV_URL; source $CSV_SRC }
# make installation permanent
csv.install() { if [[ -z `grep csv-functions.sh $PROFILE` ]]; then echo "source $CSV_SRC" >> $PROFILE; fi }
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