Skip to content

Instantly share code, notes, and snippets.

@Kedrigern
Last active March 13, 2016 15:38
Show Gist options
  • Save Kedrigern/025b3a71a25f920a0a4c to your computer and use it in GitHub Desktop.
Save Kedrigern/025b3a71a25f920a0a4c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# usage: ./check.sh *.csv
# Check if given csv have correct format for currency.
col_money="4 6"
col_date="17 18 19 20"
lines="2 3 4"
for f in $@; do
if file "$infile" | grep "UTF-8"; then
echo "[OK] Encoding";
else
echo "[ERR] Encoding";
fi;
for c in $col_money; do
re="^[0-9]+(\.[0-9]{1,2})*$"
for i in $lines ; do
castka=$( sed -n "${i}p" "$f" | cut -d ';' -f ${c} )
if [[ $castka =~ $re ]]; then
echo "[OK] currency format: $castka";
else
echo "[ERR] line: $i, column: $c, value: $castka, wrong: currency format";
fi;
done;
done;
# TODO: date
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment