parsing excel documents avec python

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

parsing excel documents avec python

Message par ForumBot »

I want to parse excel document to lists in Python.
Is there a python library which is helpful for this action?
And what functions are relevant in that library?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: parsing excel documents avec python

Message par ForumBot »

You're best bet for parsing Excel files would be the [xlrd](http://pypi.python.org/pypi/xlrd) library. The [python-excel.org](http://www.python-excel.org/) site has links and examples for [xlrd](http://pypi.python.org/pypi/xlrd) and related python excel libraries, including a [pdf document](http://www.simplistix.co.uk/presentations/python-excel.pdf) that has some good examples of using xlrd. Of course, there are also lots of [related xlrd questions](https://stackoverflow.com/search?q=python%20xlrd) on StackOverflow that might be of use.

One caveat with the xlrd library is that it will only work with `xls` (Excel 2003 and earlier versions of excel) file formats and not the more recent `xlsx` file format. There is a newer library [openpyxl](https://bitbucket.org/ericgazoni/openpyxl/wiki/Home) for dealing with the `xlsx`, but I have never used it.

**UPDATE**:
As per John's comment, the [xlrd](http://pypi.python.org/pypi/xlrd) library now supports both `xls` and `xlsx` file formats.

Hope that helps.
Répondre

Revenir à « Excel & VBA »