forked from euctrl-pru/portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateCSV
104 lines (86 loc) · 2.33 KB
/
updateCSV
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
#
#-- Version: 1.0
#-- Author: Enrico Spinielli
#-- Date: 2016/04/18
#-- Copyright (C) 2016 Eurocontrol/PRU
##- Usage: updateCSV
##- Extract all PRU download point CSV files
##-
##- This script relies on the following ENV variables
##- HFEDBUSR env var for the HFE dataset's schema user.
##- HFEDBPWD env var for the HFE dataset's schema password.
##- YYYDBUSR env var for the other's datasets schema username.
##- YYYDBPWD env var for the other's datasets schema password.
##- DBNAME env var for the relevant schema name.
##- Options:
##- -h, --help Print a usage message summarizing the command-line options, then exit.
##- -V, --version Output version information and exit.
##-
##- Examples:
##- $ updateCSV
##-
##- Caveat: be sure to use gnu-getopt and not OSX builtin or Git Bash missing one ;-)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT="$(basename "${BASH_SOURCE[0]}")"
help=$(grep "^##-" "${SCRIPT_DIR}/${SCRIPT}" | cut -c 4-)
version=$(grep "^#--" "${SCRIPT_DIR}/${SCRIPT}" | cut -c 4-)
opt_h() {
echo "$help"
}
opt_v() {
echo "$version"
}
# Execute getopt
TEMP=$(getopt -o :hV --long "help,version" -n "${SCRIPT}" -- "$@");
if [ $? != 0 ]
then
echo "Invalid option(s): $*" >&2
exit 1
fi
eval set -- "$TEMP"
unset TEMP
while true; do
case $1 in
-h|--help)
opt_h
exit
;;
-V|--version)
opt_v
exit
;;
--)
shift
break
;;
\?)
echo "Invalid option: -$OPTARG" >&2
opt_h
exit 1
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
# there are NO mandatory arguments
if (( $# != 0 )); then
echo "Error: illegal number of parameters"
opt_h
exit 1
fi
APT_DLY_WEF=2014-01-01
ERT_DLY_WEF=2018-01-01
TIL=2019-03-01
(
cd "${SCRIPT_DIR}/" || exit;
Rscript R/export_ert_dly.R -t ansp ${ERT_DLY_WEF} ${TIL};
Rscript R/export_ert_dly.R -t fir ${ERT_DLY_WEF} ${TIL};
Rscript R/export_apt_dly.R ${APT_DLY_WEF} ${TIL};
Rscript R/export_hfe.R;
Rscript R/generate_ert_flt_percent_chage.R ${TIL};
Rscript R/generate_monthly_ert_dly_fab_fir.R;
Rscript R/export_ansp_composition.R ${TIL};
)