PyExcelerator: How does one close a file?

tkpmep at hotmail.com tkpmep at hotmail.com
Tue May 9 23:57:57 CEST 2006


I use PyExcelerator to write data into Excel files, and repeatedly call
the function writeData with different filenames fn from my main
routine. Unfortunately, only one file - the last one - is created. The
problem seems to lie with the fact that I do not close the existing
file before calling the function again, and the existing file is
therefore just saved with a new name. Is there a way to close a
PyExcelerator Excel file so that each call to the function results in a
new file? There is no close() method as far as I can tell.

def writeData(fn, Data):
    """Write the data into an Excel file named fn using PyExcelerator
        Data is a list of real numbers"""
    w=PyExcelerator.Workbook()
    ws = w.add_sheet("Sheet1")
    for i in range(len(Data)):
        ws.write(i, 0, Data[i])
    w.save(fn)

Thanks in advance

Thomas Philips




More information about the Python-list mailing list