Writing a novel seems like a daunting task. 90,000 words is a lot.
However, working in the knowledge economy, I do write a lot. Chances are that you do as well. Slack messages, Github tickets, emails (luckily, not very often) and of course, notes. This got me thinking – how much do I write?
I decided to start with counting the number of words in my notes, as it's the content that I have the most control over. Since August 2023, I've been using Logseq exclusively to write down (mostly) work notes, including a daily log of what I am doing, to-do lists, meeting notes, and other things that need to be jotted down. Logseq is great for many reasons, including the fact that notes are stored as Markdown files. Because that effectively means they're just text files, my notes will be accessible and compatible forever.
It also means that I can use Python to calculate the number of words I've written.
Calculating my word count
Logseq is structured around a daily journal, and most files are stored as yyyy_mm_dd.md
inside of a journals
folder. Knowing this, I wrote a Python script to calculate the number of words written in each of these files. The number of words can be aggregate based on the month or year that I'd like.
We first define a pattern:
pattern = "journals/" + str(year) + "_" + str(month) + "*"
Replacing year
or month
with the *
wildcard identifies filenames with any year or any month, respectively.
We then loop through all files in the journals
folder that meet the pattern
definition. Each file's contents are then split
into a list, on spaces. The length of the string is then calculated and added to a number_of_words
variable.
for f in glob.iglob(pattern):
# Opening our daily journal file in read only mode using the open() function
with open(f,'r') as file:
# Read the content of the file using the read() function and store them in a new variable
data = file.read()
# Split the string into a list using the split() function
lines = data.split()
# Calculate and adding the length of the lines in our number_of_words variable
number_of_words += len(lines)
In roughly 5 months in 2023 (from August 11th), I wrote 33,881 words. That's roughly 6,700 words per month, or roughly 80,000 words per year – almost the length of an average book!
I've written 58110 words worth of notes in 2024, as of 2024/11/05.
Caveats
80,000 words per year only accounts for most of my notes. This method doesn't account for all of the Slack messages, emails, Google/Word docs, WhatsApp/Signal messages, or any other keystrokes or screen taps, so it's most certainly an undercount. I'm only indexing "daily" notes, and not dedicated pages of notes that Logseq stores in a different folder, further under counting the total.
Regardless, it's nice to know that I'm writing a lot more than I thought.
Next Steps
I added my word count as a tally for the current year in the footer of post and project pages on this site. The words.py
script outputs a .json file, that is then read when this website is built (read: update). Unfortunately, it's a manual process – I need to run words.py
and then push my site to Github to have it rebuild. A better approach would be to run words.py
daily and have this website build daily as well.
Still, it's a nice reminder of the many words I write.