From 2a9296b9a4a72f13b87df2e18cae2edb098a11e7 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 20 Mar 2023 21:05:56 +0000 Subject: [PATCH] clean-up and rename separator.sh file to fix typo. For some reason, I have a habit of spelling separator as 'seperator' and it takes my a while to notice the mistake. Clean-up involves adding comments and removing unused code. --- seperator.sh => separator.sh | 43 +++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) rename seperator.sh => separator.sh (56%) mode change 100755 => 100644 diff --git a/seperator.sh b/separator.sh old mode 100755 new mode 100644 similarity index 56% rename from seperator.sh rename to separator.sh index d39c9aa..6804a01 --- a/seperator.sh +++ b/separator.sh @@ -1,15 +1,36 @@ #!/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"; -} +# SEPARATOR +# ============================================================================== +# This script takes the lm1-exhibition-all.csv and lm2-exhibition-all.csv files +# and splits the readings down into daily and hourly segments. The breakdowns +# are placed in their own directories and should look like the following: + +# data +# ├── light-meter-1 +# | │   ├── hourly readings directory (E.G. 2021-07-14/) +# | │   |   └──hourly reading files (E.G. 2021-07-14--14.csv) +# | │   └── hourly readings directory (E.G. 2021-07-15/) +# | │      └── hourly reading files (E.G. 2021-07-15--17.csv) +# │   └── daily readings files (E.G 2021-07-14.csv) +# │   └── daily readings files (E.G 2021-07-15.csv) +# ├── light-meter-2 +# |    └── repeats light-meter-1 structure... +# ├── lm1-exhibiton-all.csv +# └── lm2-exhibiton-all.csv +# +# 2 directories, 2 files + +# Note: Naming Format for Hourly Breakdowns (YYYY-MM-DD--HH) +# ============================================================================== +# The last part of the file name specifies the hour the readings were taken +# from. So, '2021-07-15--17.csv' means the readings for that file were taken on +# the 15th July 2021 between 17:00 and 18:00 (5pm and 6pm). hourBreakdown () { - d="$1"; # Day - m="$2"; # Month + d="$1"; # Day + m="$2"; # Month mtr="$3"; # Light Meter (either 1 or 2) - # echo "Day: $d | Month: $m | Meter: $mtr"; mkdir -p "data/light-meter-$mtr/2021-$m-$d"; for hour in {0..24}; do if [[ $hour -lt 10 ]]; then @@ -27,8 +48,6 @@ dailyBreakdown () { mkdir -p "data/light-meter-$lm"; for month in {6..8} ; do for day in {1..31} ; do - # echo "2021-0$month-$day Meter: $1"; - # hourBreakdown $day $month $lm; if [[ $day -lt 10 ]]; then touch "data/light-meter-$lm/2021-0$month-0$day.csv"; echo "time,reading" > "data/light-meter-$lm/2021-0$month-0$day.csv"; @@ -52,7 +71,5 @@ dailyBreakdown () { done } -# singleBreakdown -dailyBreakdown "1"; -dailyBreakdown "2"; -# hourBreakdown +dailyBreakdown "1"; # Light Meter 1 +dailyBreakdown "2"; # Light Meter 2