#!/bin/sh
# csv2tbl fieldSep format in out

if [ $# -lt 4 ] ; then
    echo "$0 fieldSep tblFormat inFile outFile" >&2
    echo >&2
    exit 1
fi

FIELD_SEP=$1
TABLE_FORMAT=$2
IN_FILE=$3
OUT_FILE=$4

AWK_FILE=$(dirname $0)/csv2tbl.awk

awk -F"${FIELD_SEP}" \
    -v tblFormat="${TABLE_FORMAT}" \
    -f "${AWK_FILE}" \
    ${IN_FILE} > ${OUT_FILE}
