Added with the new exclusion rules.
[tarificador.git] / parse_dir.sh
blob44e312461eeb83e8f859f3f14f3aac457b784586
1 #!/bin/bash
2 # Acept a directory with csvs to parse
4 #DEBUG='echo'
5 TARIFICADOR="/home/the00z/neuroservices/tarificador/put"
6 DIR="$1"
8 find "$DIR" -type d | grep -v -G "^$DIR$" | sort | while read SUBDIR
9 do
10 TMP=$( find "$SUBDIR" -iname '*csv*')
12 # if there are no modified csvs then use the normal csv.
14 if ! CSV=$( grep -i 'mod' <<<"$TMP");then
15 if ! CSV=$(grep -i 'master.csv' <<<"$TMP"); then
16 continue
20 CSV=$(sed -ne '/\(csv\|mod\)$/p'<<<"$CSV")
21 EDIFICIO="'$(sed -e 's/^\(.*\/\)\?\([[:digit:]]\+\)[[:space:]].*$/\2/g' \
22 <<<"$CSV")'"
23 echo "$TARIFICADOR" "'$CSV'" "'$EDIFICIO'" >/dev/stderr
24 eval "$TARIFICADOR" "'$CSV'" "'$EDIFICIO'"
26 echo '###############################################'
27 done