3

I have some (Excel 2000) workbooks. I want to extract the data in each worksheet to a separate file.

I am running on Linux.

Is there a library I can use to access (read) XLS files on Linux from Python?

4
  • could always export the excel spreadsheet to csv format which should be easy to parse in Python Commented Dec 4, 2010 at 19:42
  • 5
    Did you have a look at python-excel.org? Commented Dec 4, 2010 at 19:42
  • Or save as XML and use XML parser. Commented Dec 4, 2010 at 19:44
  • +1 @Sven, python-excel looks perfect. Commented Dec 4, 2010 at 19:44

4 Answers 4

7

http://www.lexicon.net/sjmachin/xlrd.htm might work for you.

Sign up to request clarification or add additional context in comments.

2 Comments

+1: xlrd has always worked flawlessly for me. It does not read the latest Excel format yet, unfortunately.
@EOL: An "alpha" version of code that reads Excel 2007 xls[xm] files is available by e-mail request to serious testers. Just ask.
3

Get xlrd from PyPI. Also go to the python-excel website to find out about (a) a tutorial (b) a discussion group (c) xlwt and xlutils.

[Dis]claimer: I'm the author & maintainer of xlrd, and maintainer of xlwt (which is a fork of pyExcelerator with bugs fixed and numerous enhancements).

Comments

0

The easiest way would be to run excel up under Wine or as a VM and do it from Windows. You can use Mark Hammond's COM bindings, which come bundled with ActiveState Python. Alternatively, you could export the data in CSV format and read it from that.

3 Comments

I'd be interested in your reasons for saying that win32 COM + Excel would be easier than xlrd
Gives you access to named ranges and the whole Excel API. I have used xlrd and it works pretty much cell by cell. You can get a whole sheet out at a time and work with it en masse through the API.
xlrd gives access to named ranges. The OP is on Linux and wants to extract the data(for which xlrd provides row-at-a-time access); he doesn't need "the whole Excel API" and the whole overhead of setting up a Windows-compatible environment and probably doesn't even have/want a licenced copy of Excel.
-1

I've been using pyexcelerator for this purpose in the past with good results.

3 Comments

currently this is better performed with xlrd and xlwt libraries. AFAIK pyexcelerator is not maintained anymore
-1 pyExcelerator ia abandonware (check out the bug tracker on sourceforge). Its xls reading component has minimal functionality.
@joaquin: maybe, just telling from own experience (we had some code written with it in production) and I've checked, it is still in the repo :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.