Word Count Dataview Query

What I’m trying to do

Pull word count for particular notes into a dataview table so that I can keep an eye on chapter totals. I don’t want to have to manually put the totals into yaml but I will if there isn’t another way. I was hoping there might be a way with one of the word count plugins, but I haven’t been able to find anything.

Essentially, I have yaml fields for Type: Scene, Book: Book 1, Chapter: 1

So I’d like to have a dataview query that will take all of the Scenes from Book 1, Chapter 1, and tell me how many words total. The reason I don’t want to put the word count in yaml is because it might change and I don’t want to have to edit it each time.

Things I have tried

Looked on the forums, reddit, googled. It’s probably not possible right now but I wanted to double check.

Hi @kiru! Unfortunately Dataview does not see the text contents of your notes – only the metadata, fields, tasks, and list items. So it’s not possible to have Dataview count your words for you.

To use Dataview for this, you would need to put the word count into a YAML or inline field, and then you could use Dataview to count it all up.

I would guess there are some word-count plugins that could get you close to where you’re trying to go, but I don’t know.

Hope this helps,

Craig

A similar request came up recently, where I suggested guestimating these values, since to my knowledge these values are not easily accessible. See answer below:

Since you’re not dealing with the entire vault you might put together a script to do the actual count, but I do believe for most purposes the guesstimate would serve you well enough with changing the variable according to your setup for the size of the frontmatter and a proper ratio related to markup versus actual text.

These values can be found/calculated by comparing the output of the query and the actual word count of some of your chapter notes.

Thanks holroy. I might have to play with it and see how close I can tweak it. An good estimate should be sufficient, even if my perfectionism chafes! I’m hoping that eventually one of the word count apps will somehow make this possible but until then, this might do me. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.