[Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

Bill Burns billburns at pennswoods.net
Sat Dec 31 01:12:16 CET 2005


[snip]

Paul Kraus wrote:
> Now I have to find a way to take the output at the end and pipe it
> out to an external Perl program that creates an excel spreadsheet (
> no real clean easy way to do this in python but hey each tool has its
> usefullness). I wish I could hide this in the object though so that I
> could call a "dump" method that would then create the spreadsheet. I
> will have to play with this later.

[snip]

Hi Paul,

For the Excel portion of things, you may want to take a look at
pyExcelerator.

http://sourceforge.net/projects/pyexcelerator

I had never tried it (until I read your post), so I though I'd give it a
try. There are others on the list who have used it (John Fouhy & Bob
Gailer, I believe, maybe others??).

It seems very good a writing Excel files. It does not require COM or
anything such as that, but you will need Python 2.4. It is supposed to
run on both Windows and *nix (I've only tested it on Windows).

I've no idea what your output data looks like, but here's a small
example which uses the fields (from your previous code) and writes
them to an Excel file.

<code>

from pyExcelerator.Workbook import *

wb = Workbook()
ws0 = wb.add_sheet('Vendor_Sales')

fields = \
'vendor,otype,oreturn,discountable,discperc,amount,date'.split(',')

row = 0
col = -1
for field in fields:
     col += 1
     ws0.write(row, col, field)

wb.save('Vendor_Sales.xls')

</code>

It's a small download (approx. 260 KB) and easy to install
(python setup.py install).

It seems a little 'light' in the documentation area, but there are
various examples in the zip file.

HTH,

Bill




More information about the Tutor mailing list