How can I count words in complex documents (.rtf, .doc, .odt, etc)?

限于喜欢 提交于 2019-12-04 09:27:59

load the documents in a headless OOo and call its word-count function

PyODConverter is a recent (11-2009) script to use OOo to convert multiple file types. Looking at the script, it has basic loading of all the OOo supported documents.

This is how you start OOo as a headless service:

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

Then you just have to write a small bootstrapper that calls OOo on the commandline, runs your script, then closes OOo.


This could be not the option for you, but in case it is - you can upload documents to Google Docs and then export in .txt format. Google usually does very nice job for the conversion.

You can find relevant APIs here: http://code.google.com/intl/pl/apis/documents/docs/1.0/developers_guide_python.html

Take a look at login, uploading and exporting sections.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!