diff --git a/client-gui2 b/client-gui2 index d69f3b50..e87bff75 160000 --- a/client-gui2 +++ b/client-gui2 @@ -1 +1 @@ -Subproject commit d69f3b5068931a6b4c7a3245f051e586b96d4d92 +Subproject commit e87bff759a1e398ca0ac08e3c66921cc2ca98858 diff --git a/prod_data_parse_scripts/parse_uc_osnova.sh b/prod_data_parse_scripts/parse_uc_osnova.sh index 7bcdecbd..46cb54e7 100644 --- a/prod_data_parse_scripts/parse_uc_osnova.sh +++ b/prod_data_parse_scripts/parse_uc_osnova.sh @@ -11,7 +11,7 @@ input=$1 output=${2:--} process_csv() { - awk -F ',' ' + awk -F '\",\"' ' function clean_account(value, quoted) { quoted = substr(value, 1, 1) == "\"" && substr(value, length(value), 1) == "\"" @@ -44,7 +44,7 @@ process_csv() { } BEGIN { - OFS = "," + OFS = FS } { @@ -61,7 +61,7 @@ process_csv() { key = key_value(cleaned) if (key == "") { - cleaned = "\"000\"" + cleaned = "000" key = "000" } diff --git a/prod_data_parse_scripts/parse_uctovnictvo.sh b/prod_data_parse_scripts/parse_uctovnictvo.sh new file mode 100755 index 00000000..37e0433a --- /dev/null +++ b/prod_data_parse_scripts/parse_uctovnictvo.sh @@ -0,0 +1,75 @@ +#!/bin/sh + +set -eu + +if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then + printf 'Usage: %s INPUT.csv [OUTPUT.csv]\n' "$0" >&2 + exit 2 +fi + +input=$1 +output=${2:--} + +process_csv() { + awk -F '\",\"' ' + function clean_account(value) { + if (length(value) > 0 && substr(value, length(value), 1) !~ /[0-9]/) { + while (length(value) > 0 && substr(value, length(value), 1) !~ /[0-9]/) { + value = substr(value, 1, length(value) - 1) + } + } + + return value + } + + function zero_amount_to_empty(value) { + if (value == "0.00") { + return "" + } + + return value + } + + BEGIN { + OFS = FS + } + + NR == 1 { + print + next + } + + { + cleaned = clean_account($10) + + if (cleaned == "") { + cleaned = "000" + } + + key = cleaned + key_count[key]++ + if (!(key in key_order)) { + key_order[key] = ++key_total + } + + $10 = cleaned + $11 = zero_amount_to_empty($11) + $12 = zero_amount_to_empty($12) + print + } + + END { + for (key in key_order) { + if (key_count[key] > 1) { + printf "Non-unique column 10 key: %s (%d rows)\n", key, key_count[key] > "/dev/stderr" + } + } + } +' "$input" +} + +if [ "$output" = "-" ]; then + process_csv +else + process_csv > "$output" +fi