[Tutor] Excel files to Tab delim files

John Fouhy john at fouhy.net
Thu Jan 5 23:52:30 CET 2006


On 06/01/06, Srinivas Iyyer <srini_iyyer_bio at yahoo.com> wrote:
> Dear group,
>  is there any library available that would convert
> over 2000 .xls files to tab delim text files.

Check out pyExcelerator: http://sourceforge.net/projects/pyexcelerator

The documentation is a bit light, but basically, if you do:

import pyExcelerator
workbook = pyExcelerator.parse_xls('myFile.xls')

then workbook will be a data structure looking like [(sheet name, {
(row, col): data })]

ie: a list of tuples, where the first element is the sheet name (eg,
u'Sheet 1', u'Sheet 2') and the second element is a dictionary whose
keys are (int, int) pairs representing cells (where A1 is (0, 0)) and
whose values are the values of the cells.

>From that, you should be able to easliy produce a tab delimited file
(or anything else you want).

The only issue I have had with it is that it reads integers as
strings, but I haven't looked at the latest version so this may be
fixed, and if you're just writing out to CSV file that won't matter
anyway.
[be aware, though, that any dates in the spreadsheet will turn into integers]

--
John.


More information about the Tutor mailing list