Last active
March 13, 2016 15:38
-
-
Save Kedrigern/025b3a71a25f920a0a4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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