#!/bin/sh -e
#
# ,awkarr - print the given column of the csvfile as list (pythonic)
# usage: ,awkarr <col> <csvfile>

if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  printf '%s\n' "$(basename "$0") [col] [csvfile]"
  exit 1
fi

column="$1"
shift

awk -F ',' -v COL="${column}" '{ print $COL }' "$@" | tr -s '\r\n' ',' \
  | sed -e 's/,$//'
