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__":