简体   繁体   中英

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM