Files
apple-health-export-processing/merge.sh

27 lines
482 B
Bash
Executable File

#! /bin/bash
# Script to merge output from other files in this repo into a single csv
SOURCES="steps.csv sleep-mins.csv"
# Write header
echo -n "Date"
for s in $SOURCES
do
echo -n ,
echo -n $s | cut -z -d. -f1
done
echo ""
# For each unique date...
cat $SOURCES | cut -d, -f1 | sort -u | while read d
do
LINE="$d"
# ...collect the result from each source
for s in $SOURCES
do
LINE="$LINE,"`grep $d $s | cut -d, -f 2`
done
echo $LINE
done