Jonas Trusbak
Jonas Trusbak

Reputation: 11

Python: Open .doc file with antiword on windows

I am trying to open a bunch of .doc files (not docx) in a folder using python.

I downloaded a modified "antiword" which was a precompiled execute file for windows as the original antiword is only available for linux.

http://www-stud.rbi.informatik.uni-frankfurt.de/~markus/antiword/

After I downloaded it I insert it into my python27 folder and I run the antiword.exe file.

honestly my problem is that I do not understand what is going on when I run the execute. I had hoped that it would add a library to my python directory and I could the import "antiword". Can anyone help me?

Thanks a lot.

BR Jonas

Upvotes: 0

Views: 3369

Answers (1)

Ali Elbehery
Ali Elbehery

Reputation: 111

As I understand, antiword is not a python module that you can import. It's an executable that can be run directly from the command prompt (cmd). I installed antiword as explained in 00README.WIN document and could run it in cmd after adding its folder to PATH environment variable as well as creating a HOME environment variable exactly as outlined in README. I could successfully run the following example using testdoc.doc found in antiword\Doc\

antiword -m cp852.txt filename.doc > filename.txt

I think if you need to do this in Python, you can run antiword similar to any cmd command as previously explained. The same thing was previously suggested. You could also give IronPython a try as previuosly recommended.

I hope this helps!

Upvotes: 2

Related Questions