Browse Source

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.
master
Craig Oates 1 year ago
parent
commit
dd1d5a091d
  1. 51
      seperator.sh

51
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
Loading…
Cancel
Save