Added sleep.csv. Added merged.csv. Renamed steps.sh
This commit is contained in:
21
sleep-day.sh
Executable file
21
sleep-day.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Script to extract Huawei watch sleep time from Apple Health full export
|
||||
# into a csv file
|
||||
|
||||
cat export.xml |
|
||||
grep 2024- |
|
||||
grep 'type="HKCategoryTypeIdentifierSleepAnalysis" sourceName="HUAWEI Health"' |
|
||||
egrep -o 'startDate[^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ ' |
|
||||
while read line
|
||||
do
|
||||
START=`echo $line | cut -d\" -f2`
|
||||
END=`echo $line | cut -d\" -f4`
|
||||
START_TS=`date --date="$START" +"%s"`
|
||||
END_TS=`date --date="$END" +"%s"`
|
||||
TIME=`expr $END_TS - $START_TS`
|
||||
DATE=`echo $START | cut -d\ -f1`
|
||||
echo $DATE $TIME
|
||||
done |
|
||||
awk '{ sleep[$1]=sleep[$1]+$2 } END { for (date in sleep) { print date "," sleep[date] / 60} }' |
|
||||
sort >sleep-mins.csv
|
||||
Reference in New Issue
Block a user