Skip to content

Instantly share code, notes, and snippets.

@unfo
Created April 24, 2012 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unfo/2479372 to your computer and use it in GitHub Desktop.
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
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