From dd1d5a091d7c4e4ffd2e91e1e1c0eab22241be84 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 20 Mar 2023 18:10:25 +0000 Subject: [PATCH] create seperator.sh file. This shell script takes the data from data/lm1-exhibition-all.csv and breaks it down into readings taken on a daily scale and then an hourly scale. At the moment, it produces directories and files for times/days which have no readings but I don't know if that's relevant or not. By having no data in certain files, it does confirm 'No Data Recorded' if/when people look to review the data and wonder why they can't find any for a particular day. --- seperator.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 seperator.sh diff --git a/seperator.sh b/seperator.sh new file mode 100755 index 0000000..64ff4c5 --- /dev/null +++ b/seperator.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +singleBreakdown () { + echo "time,reading" > "data/light-meter-1/2021-06-14.csv";n + grep "2021-06-14" "datalm1-exhibiton-all.csv" >> "data/light-meter-1/2021-06-14.csv"; +} + +hourBreakdown () { + d="$1"; # Day + m="$2"; # Month + # echo "Day: $d | Month: $m"; + mkdir "data/light-meter-1/2021-$m-$d"; + for hour in {0..24}; do + if [[ $hour -lt 10 ]]; then + echo "time,reading" > "data/light-meter-1/2021-$m-$d/2021-$m-$d--0$hour.csv"; + rg "2021-$m-$d 0$hour:" "data/light-meter-1/2021-$m-$d.csv" >> "data/light-meter-1/2021-$m-$d/2021-$m-$d--0$hour.csv"; + else + echo "time,reading" > "data/light-meter-1/2021-$m-$d/2021-$m-$d--$hour.csv"; + rg "2021-$m-$d $hour:" "data/light-meter-1/2021-$m-$d.csv" >> "data/light-meter-1/2021-$m-$d/2021-$m-$d--$hour.csv"; + fi + done +} + +dailyBreakdown () { + for month in {6..8} ; do + for day in {1..31} ; do + # echo "2021-0$month-$day"; + if [[ $day -lt 10 ]]; then + echo "time,reading" > "data/light-meter-1/2021-0$month-0$day.csv"; + rg "2021-0$month-0$day" "data/lm1-exhibiton-all.csv" >> "data/light-meter-1/2021-0$month-0$day.csv"; + if [[ $month -lt 10 ]]; then + hourBreakdown "0$day" "0$month"; + else + hourBreakdown "0$day" "$month"; + fi + else + echo "time,reading" > "data/light-meter-1/2021-0$month-$day.csv"; + rg "2021-0$month-$day" "data/lm1-exhibiton-all.csv" >> "data/light-meter-1/2021-0$month-$day.csv"; + if [[ $month -lt 10 ]]; then + hourBreakdown "$day" "0$month"; + else + hourBreakdown "$day" "$month"; + fi + fi + done + done +} + +# singleBreakdown +dailyBreakdown +# hourBreakdown