Browse Source

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.
master
Craig Oates 1 year ago
parent
commit
dbe1a1bd62
  1. 39
      totalilator.sh

39
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
}

Loading…
Cancel
Save