Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the library to get the word count of a .doc/.docx files as reported in MS-Word ? #1453

Open
kunalsawhney opened this issue Dec 9, 2024 · 1 comment

Comments

@kunalsawhney
Copy link

I am building a solution where I want the word count of the document. One way is to traverse over all the text of document and then calculate the word count.

I am wondering if there is any better way to get the word count of the document ?

Note: I want the word count to be accurate (same as reported by MS-Word)

@scanny
Copy link
Contributor

scanny commented Dec 9, 2024

I believe that's recorded in the Dublin Core metadata, isn't it? Or perhaps one of the other properties collections.

It would not be perfectly reliable because you're counting on the client that did the most recent edit to have updated it. You can probably count on Word and probably LibreOffice as well, but it's a bit of a risk you might want to consider.

Could be more accurate though, especially if there are open revisions and python-docx ignores those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants