views:

921

answers:

6

Any recomendations on a method to convert .doc, .ppt, and .xls to plain text on linux using python? Really any method of conversion would be useful. I have already looked at using Open Office but, I would like a solution that does not require having to install Open Office.

+3  A: 

The usual tool for converting Microsoft Office documents to HTML or other formats was mswordview, which has since been renamed to vwWare.

If you're looking for a command-line tool, they actually recommend using AbiWord to perform the conversion:

AbiWord --to=txt

If you're looking for a library, start on the wvWare overview page. They also maintain a list of libraries and tools which read MS Office documents.

emk
+1  A: 

For dealing with Excel Spreadsheets xlwt is good. But it won't help with .doc and .ppt files.

(You may have also heard of PyExcelerator. xlwt is a fork of this and better maintained so I think you'd be better of with xlwt.)

Dave Webb
+5  A: 

You can access OpenOffice via Python API.

Try using this as a base: http://wiki.services.openoffice.org/wiki/Odt2txt.py

vartec
+1  A: 

At the command line, antiword or wv work very nicely for .doc files. (Not a Python solution, but they're easy to install and fast.)

Telemachus
A: 

I've had some success at using XSLT to process the XML-based office files into something usable in the past. It's not necessarily a python-based solution, but it does get the job done.

D.Shawley
+2  A: 

I'd go for the command line-solution (and then use the Python subprocess module to run the tools from Python).

Convertors for msword (catdoc), excel (xls2csv) and ppt (catppt) can be found (in source form) here: http://vitus.wagner.pp.ru/software/catdoc/.

Can't really comment on the usefullness of catppt but catdoc and xls2csv work great!

But be sure to first search your distributions repositories... On ubuntu for example catdoc is just one fast apt-get away.

ChristopheD