From dbe1a1bd629308a2cc24b021ba08f1f8d3456c98 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 21 Mar 2023 08:25:21 +0000 Subject: [PATCH] reduce amount of excess data produced with totalilator.sh script. I added checks to stop this script from processing data which was not recorded during the exhibition's opening times. Note: The exhibition officially closes on 1st August 2021 but that was a Sunday and no one was working in Ritherdon that day. This is why the looping range has been reduced from 6-8 to 6-7. --- totalilator.sh | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/totalilator.sh b/totalilator.sh index ae2a6c8..e1fb759 100755 --- a/totalilator.sh +++ b/totalilator.sh @@ -65,12 +65,18 @@ getDailyReadingTotals () { mtr=$1; # Light Meter echo "date,reading" > "data/light-meter-$mtr-daily-totals.csv"; - for month in {6..8} ; do + for month in {6..7} ; do for day in {1..31} ; do - if [[ $day -lt 10 ]]; then d="0$day"; else d="$day"; fi - if [[ $month -lt 10 ]]; then m="0$month"; else m=$month; fi - echo "2021-$m-$d, $(awk 'END{print NR-1}' "data/light-meter-$mtr/2021-$m-$d.csv")" \ - >> "data/light-meter-$mtr-daily-totals.csv"; + if [[ $month -eq 6 ]] && [[ $day -lt 13 ]]; then + : + else + if [[ $day != 31 ]] && [[ $month != "06" ]]; then + if [[ $day -lt 10 ]] ; then d="0$day"; else d="$day"; fi + if [[ $month -lt 10 ]] ; then m="0$month"; else m=$month; fi + echo "2021-$m-$d, $(awk 'END{print NR-1}' "data/light-meter-$mtr/2021-$m-$d.csv")" \ + >> "data/light-meter-$mtr-daily-totals.csv"; + fi + fi done done } @@ -78,17 +84,24 @@ getDailyReadingTotals () { getHourlyReadingTotals () { mtr=$1; # Light Meter mkdir -p "data/light-meter-$mtr-hourly-totals"; - for month in {6..8} ; do + for month in {6..7} ; do if [[ $month -lt 10 ]]; then m="0$month"; else m=$month; fi mkdir -p "data/light-meter-$mtr-hourly-totals/2021-$m" for day in {1..31} ; do - if [[ $day -lt 10 ]]; then d="0$day"; else d="$day"; fi - echo "hour,reading" > "data/light-meter-$mtr-hourly-totals/2021-$m/2021-$m-$d.csv"; - for hour in {0..24} ; do - if [[ $hour -lt 10 ]]; then h="0$hour"; else h=$hour; fi - echo "$h, $(awk 'END{print NR-1}' "data/light-meter-$mtr/2021-$m-$d/2021-$m-$d--$h.csv")" \ - >> "data/light-meter-$mtr-hourly-totals/2021-$m/2021-$m-$d.csv"; - done + if [[ $month -eq 6 ]] && [[ $day -lt 13 ]]; then + : + else + if [[ $day != 31 ]] && [[ $month != "06" ]]; then + if [[ $day -lt 10 ]]; then d="0$day"; else d="$day"; fi + echo "hour,reading" \ + > "data/light-meter-$mtr-hourly-totals/2021-$m/2021-$m-$d.csv"; + for hour in {0..24} ; do + if [[ $hour -lt 10 ]]; then h="0$hour"; else h=$hour; fi + echo "$h, $(awk 'END{print NR-1}' "data/light-meter-$mtr/2021-$m-$d/2021-$m-$d--$h.csv")" \ + >> "data/light-meter-$mtr-hourly-totals/2021-$m/2021-$m-$d.csv"; + done + fi + fi done done }