|
|
|
@ -1,7 +1,69 @@
|
|
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
# TOTALILATOR |
|
|
|
|
# ============================================================================== |
|
|
|
|
# NOTE: Must run after separator.sh script. |
|
|
|
|
|
|
|
|
|
# This script parses the files in: |
|
|
|
|
|
|
|
|
|
# - data/light-meter-1/ |
|
|
|
|
# - data/light-meter-2/ |
|
|
|
|
|
|
|
|
|
# and creates new CSV files which includes the total number of readings on a |
|
|
|
|
# given day and hour (of that day). The daily totals are stored at the top the |
|
|
|
|
# data/ directory at: |
|
|
|
|
|
|
|
|
|
# - data/light-meter-1-daily-totals.csv |
|
|
|
|
# - data/light-meter-2-daily-totals.csv |
|
|
|
|
|
|
|
|
|
# and the hourly breakdowns are stored in : |
|
|
|
|
|
|
|
|
|
# - light-meter-1-hourly-totals |
|
|
|
|
# - light-meter-2-hourly-totals |
|
|
|
|
|
|
|
|
|
# Because of the amount of files produced, I've made the script seperate each |
|
|
|
|
# hourly-based file into a directory corresponding to the month the readings |
|
|
|
|
# where taken. So, you should see a file structure similar to this, |
|
|
|
|
|
|
|
|
|
# data/ |
|
|
|
|
# └── light-meter-1-hourly-totals/ |
|
|
|
|
# ├── 2021-06 |
|
|
|
|
# │ ├── 2021-06-01.csv |
|
|
|
|
# │ ├── 2021-06-02.csv |
|
|
|
|
# │ ├── 2021-06-03.csv |
|
|
|
|
# │ ├── 2021-06-30.csv |
|
|
|
|
# │ └── 2021-06-31.csv |
|
|
|
|
# ├── 2021-07 |
|
|
|
|
# │ ├── 2021-07-01.csv |
|
|
|
|
# │ ├── 2021-07-02.csv |
|
|
|
|
# │ ├── 2021-07-03.csv |
|
|
|
|
# │ ├── 2021-07-30.csv |
|
|
|
|
# │ └── 2021-07-31.csv |
|
|
|
|
# └── 2021-08 |
|
|
|
|
# ├── 2021-08-01.csv |
|
|
|
|
# ├── 2021-08-02.csv |
|
|
|
|
# ├── 2021-08-03.csv |
|
|
|
|
# ├── 2021-08-29.csv |
|
|
|
|
# ├── 2021-08-30.csv |
|
|
|
|
# └── 2021-08-31.csv |
|
|
|
|
|
|
|
|
|
# 3 directories, 93 files (I've shorted the list for brevity) |
|
|
|
|
|
|
|
|
|
# Note: Repetitive use of file names |
|
|
|
|
# ============================================================================== |
|
|
|
|
|
|
|
|
|
# You will find I've used the date of the readings as the go-to naming |
|
|
|
|
# convention for naming files. Basically, I'm relying on the system's directory |
|
|
|
|
# structure to provide the context for the data in each file. I didn't want the |
|
|
|
|
# file names to carry the 'folder structure' and end up with longer file names |
|
|
|
|
# the deeper into the data/ directory you go. The trade-off is when viewing |
|
|
|
|
# files on their own, their file names don't provide enough context and can be |
|
|
|
|
# confusing when dealing with them in isolation (outside of the projects |
|
|
|
|
# directory structure). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getDailyReadingTotals () { |
|
|
|
|
mtr=$1; |
|
|
|
|
mtr=$1; # Light Meter |
|
|
|
|
echo "date,reading" > "data/light-meter-$mtr-daily-totals.csv"; |
|
|
|
|
for month in {6..8} ; do |
|
|
|
|
for day in {1..31} ; do |
|
|
|
@ -14,7 +76,7 @@ getDailyReadingTotals () {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getHourlyReadingTotals () { |
|
|
|
|
mtr=$1; |
|
|
|
|
mtr=$1; # Light Meter |
|
|
|
|
mkdir -p "data/light-meter-$mtr-hourly-totals"; |
|
|
|
|
for month in {6..8} ; do |
|
|
|
|
if [[ $month -lt 10 ]]; then m="0$month"; else m=$month; fi |
|
|
|
|