wordcounts = []
keep_going = True
while keep_going:
- subprocess.run(["git", "checkout", "HEAD~5"])
+ subprocess.run(["git", "checkout", "HEAD~1"])
wordcount = wordcount_at_this_sha()
date = date_at_this_sha()
if date < datetime.date(2022, 4, 1):
subprocess.run(["git", "checkout", "master"])
return sorted(wordcounts)
+def normalize_dates(wordcounts):
+ eod_wordcounts = []
+ for i in range(len(wordcounts)-1):
+ date, wordcount = wordcounts[i]
+ next_date, next_wordcount = wordcounts[i+1]
+ gap = next_date - date
+ if gap >= datetime.timedelta(1):
+ eod_wordcounts.append((date, wordcount))
+ for i in range(gap.days-1):
+ eod_wordcounts.append((date + datetime.timedelta(i+1), wordcount))
+ return eod_wordcounts
def write_csv(wordcounts):
with open("memoir_wordcounts.csv", 'w') as f:
if __name__ in "__main__":
- wordcounts = look_back()
+ wordcounts = normalize_dates(look_back())
write_csv(wordcounts)