Jpp  debug
the software that should make you happy
software/JDataQuality/qaqc.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 if [ -z $JPP_DIR ]; then
8  echo "Variable JPP_DIR undefined."
9  exit
10 fi
11 
12 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
13 
14 set_variable: DEBUG QAQC_DEBUG 0
15 
16 if do_usage $*; then
17  usage "$script <QA/QC file> [(parameter)]"
18 fi
19 
20 if (( $# == 0 )); then
21  fatal "Wrong number of arguments."
22 fi
23 
24 set_variable INPUT_FILE $argv[1]
25 set_array PARAMETERS $argv[2,-1]
26 
27 HEADER=(`head -1 $INPUT_FILE`)
28 
29 if [[ "$PARAMETERS[1]" == "?" ]]; then
30  echo $HEADER[*]
31  exit 0
32 fi
33 
34 INDICES=()
35 
36 for PARAMETER in $PARAMETERS[*]; do
37 
38  INDEX=${HEADER[(ie)$PARAMETER]}
39 
40  if (( $INDEX > ${#HEADER} )); then
41  fatal "Invalid parameter $PARAMETER."
42  else
43  INDICES+=($INDEX)
44  fi
45 done
46 
47 if (( ${#INDICES} == 0 )); then
48  INDICES=({1..${#HEADER}})
49 fi
50 
51 while read BUFFER; do
52 
53  ARRAY=(`echo $BUFFER`)
54 
55  if [[ ${(pj:\0:)HEADER} != ${(pj:\0:)ARRAY} ]]; then
56 
57  for i in $INDICES[*]; do
58  printf "%-24s %-32s\n" $HEADER[$i] $ARRAY[$i]
59  done
60  fi
61 done < $INPUT_FILE