-
Notifications
You must be signed in to change notification settings - Fork 0
/
source.csv.sh
executable file
·90 lines (74 loc) · 2.68 KB
/
source.csv.sh
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
#!/usr/bin/bash
# source.csv.sh
# v. 2022-10-05
# Reformat source data to the generic format of this system
# - competitor with variant - forking
#
# tuottaa tarvittavat pohjatiedot kilpailija- ja ratatiedoista, jotta voidaan tehda hajontatarkistus
# Kaytetaan Ocad tiedostoa ja hajonta.csv
#
PRG="$0"
BINDIR="${PRG%/*}"
[ "$PRG" = "$BINDIR" ] && BINDIR="." # - same dir as program
PRG="${PRG##*/}"
LC_ALL=fi_FI.utf8
export LC_ALL
########################################################################
usage()
{
echo "usage:$PRG -c coursesfile -t teamsvariantsfile [ -i sessioid -p tempdir -d 0/1 ] # d=debug " >&2
}
########################################################################
# MAIN
########################################################################
debug=0
html=0
# file include courses, controls and variant information
coursefile=""
# file include information combination team, leg, variant
teamvariantfile=""
myid=$$.$(date '+%s')
# uniq temporary dir for this process
tmpdir="tmp/$myid"
while [ $# -gt 0 ]
do
arg="$1"
case "$arg" in
-d) debug=$2; shift ;;
-c) coursefile=$2; shift ;;
-t) teamvariantfile=$2; shift ;;
-i) myid="$2" ; tmpdir="tmp/$myid"; shift ;;
-p) tmpdir="$2" ; shift ;;
-w) html=1; shift ;;
-*) usage; exit 99 ;;
*) shift; break ;;
esac
shift
done
[ "$coursefile" = "" ] && echo "need courses" >&2 && exit 20
[ "$teamvariantfile" = "" ] && echo "need team+variant datafile" >&2 && exit 21
[ ! -f "$coursefile" ] && echo "can't open file $coursefile" >&2 && exit 22
[ ! -f "$teamvariantfile" ] && echo "can't open file $teamvariantfile" >&2 && exit 22
resdir="$tmpdir/results"
#lahde=lahdedata/hajonta.csv
# classes
gawk -f "$BINDIR/get.class.csv.awk" "$teamvariantfile" > "$resdir/check.class.csv"
# teams
# D16|1690|1|1J4
gawk -f "$BINDIR/get.teams.csv.awk" "$teamvariantfile" > "$resdir/check.teams.csv"
# variants - forking
# iof xml 2.0.3 and iof 3.0
#gawk -f "$BINDIR/get.data.awk" -i "$BINDIR/getXML.awk" "$coursefile" | gawk -f get.variants.ocad.awk > "$resdir/check.variants.csv"
# code2code - legs - rastivalit
# diff ver iof 2.0.3 and 3.0
ver=2 # oletus
verstr=$(grep 'iofVersion="3.0"' "$coursefile" 2>/dev/null)
[ "$verstr" != "" ] && ver=3
case "$ver" in
2)
gawk -f "$BINDIR/get.data.awk" -i "$BINDIR/getXML.awk" "$coursefile" | gawk -v debug=$debug -f "$BINDIR/get.controls.iof2.awk" > "$resdir/check.controls.csv"
;;
3)
gawk -f "$BINDIR/get.data.awk" -i "$BINDIR/getXML.awk" "$coursefile" | gawk -v debug=$debug -f "$BINDIR/get.controls.iof3.awk" > "$resdir/check.controls.csv"
;;
esac