check in
[Ultimately_Untrue_Thought.git] / notes / memoir_wordcounts.py
index 44ba04f..ac1aec4 100755 (executable)
@@ -41,7 +41,7 @@ def look_back():
         subprocess.run(["git", "checkout", "HEAD~1"])
         wordcount = wordcount_at_this_sha()
         date = date_at_this_sha()
-        if date < datetime.date(2022, 4, 1):
+        if date < datetime.date(2022, 4, 20):
             keep_going = False
         wordcounts.append((date, wordcount))
     # don't leave the head detached
@@ -63,8 +63,11 @@ def normalize_dates(wordcounts):
 def write_csv(wordcounts):
     with open("memoir_wordcounts.csv", 'w') as f:
         writer = csv.writer(f)
+        previous = None
         for date, wordcount in wordcounts:
-            writer.writerow([date.strftime("%m/%d/%Y"), wordcount])
+            diff = wordcount - previous if previous is not None else ''
+            writer.writerow([date.strftime("%m/%d/%Y"), wordcount, diff])
+            previous = wordcount
 
 
 if __name__ in "__main__":