Created
April 24, 2012 12:49
-
-
Save unfo/2479372 to your computer and use it in GitHub Desktop.
Interleave two different datapoint count csv files to fill all minutes of a day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for h in {0..23} | |
do | |
for m in {0..59} | |
do | |
# .csv format: | |
# 00:07,2 | |
# 00:10,17 | |
# this combines single.csv and all csv to so that all minutes of the day are counted | |
# all.csv includes single.csv numbers, but we want em separate | |
ts=`printf "%02d:%02d" $h $m` | |
a=`fgrep $ts single.csv | cut -d',' -f2` | |
b=`fgrep $ts all.csv | cut -d',' -f2` | |
if [ -z $a ] ; then | |
if [ -z $b ] ; then | |
echo "$ts,0,0" | |
else | |
echo "$ts,0,$b" | |
fi | |
else | |
echo "$ts,$a,$b" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment