By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

pyExcelerator bug?

P: n/a
My program creates three lists: the first has dates expressed as
strings, the second has floats that are strictly positive, and the
third has floats that are strictly negative. I have no trouble writing
the data in these lists to a .csv file using the csv module using the
following code.

outfile = file(fn + '.csv','wb')
writer = csv.writer(outfile)
for i in range(len(dateList)):
writer.writerow([dateList[i], posVals[i], negVals[i]])
outfile.close()

However, when I try to write to an Excel file using pyExcelerator (see
code below), the third list is not always written correctly - my
program sometimes writes positive numbers into the third column of the
spreadsheet. Is this a known bug? if so, is there a workaround? Is
pyExcelerator being developed any longer? My attempts to reach the
developer have gone nowhere.

w = pyExcelerator.Workbook()
ws = w.add_sheet(fn + p)
for i,d in enumerate(dateList):
ws.write(i+1, 0, dateList[i])
ws.write(i+1, 1, posVals[i])
ws.write(i+1, 2, negVals[i])
w.save(fn+'.xls')

Sincerely

Thomas Philps

May 16 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On May 16, 4:42 pm, tkp...@hotmail.com wrote:
My program creates three lists: the first has dates expressed as
strings, the second has floats that are strictly positive, and the
third has floats that are strictly negative. I have no trouble writing
the data in these lists to a .csv file using the csv module using the
following code.

outfile = file(fn + '.csv','wb')
writer = csv.writer(outfile)
for i in range(len(dateList)):
writer.writerow([dateList[i], posVals[i], negVals[i]])
outfile.close()

However, when I try to write to an Excel file usingpyExcelerator(see
code below), the third list is not always written correctly - my
program sometimes writes positive numbers into the third column of the
spreadsheet. Is this a known bug? if so, is there a workaround? IspyExceleratorbeing developed any longer? My attempts to reach the
developer have gone nowhere.

w =pyExcelerator.Workbook()
ws = w.add_sheet(fn + p)
for i,d in enumerate(dateList):
ws.write(i+1, 0, dateList[i])
ws.write(i+1, 1, posVals[i])
ws.write(i+1, 2, negVals[i])
w.save(fn+'.xls')

Sincerely

Thomas Philps
Try using this patch on Cell.py and see if it fixes your problem:

--- Cell.py (revision 4522)
+++ Cell.py (revision 4523)

@@ -101,6 +101,14 @@
def get_biff_data(self):
+ return BIFFRecords.NumberRecord(self.__parent.get_index() ,
self.__idx, self.__xf_idx, self.__number).get()
+ # Skipping all the logic below.
+ # From what I understand it tries to save space.
+ # Unfortunately it gets it wrong and produces false results.
+ # For example:
+ # 814289000 gets written out as -259452824
+

May 20 '07 #2

P: n/a
On 21/05/2007 7:01 AM, Waldemar Osuch wrote:
On May 16, 4:42 pm, tkp...@hotmail.com wrote:
>My program creates three lists: the first has dates expressed as
strings, the second has floats that are strictly positive, and the
third has floats that are strictly negative. I have no trouble writing
the data in these lists to a .csv file using the csv module using the
following code.

outfile = file(fn + '.csv','wb')
writer = csv.writer(outfile)
for i in range(len(dateList)):
writer.writerow([dateList[i], posVals[i], negVals[i]])
outfile.close()

However, when I try to write to an Excel file usingpyExcelerator(see
code below), the third list is not always written correctly - my
program sometimes writes positive numbers into the third column of the
spreadsheet. Is this a known bug?
[looks like my (earlier) reply to the original post didn't make it to
c.l.py]

This may well be a manifestation of the RK bug that is reported in two
bug reports (1509223 and 1596642) on the pyExcelerator sourceforge site.
However it is impossible to tell for sure, as the OP has supplied
neither an executable demonstration script nor any
actual-versus-expected numbers.
>if so, is there a workaround?
Yes. In fact there are three:
(1) An avoid-the-problem patch (doesn't create RK records), like Waldemar's.
(2) A patch that corrects the pyExcelerator code -- see patch number
1618443 on the pyExcelerator sourceforge site.
(3) A fix that creates RK records more efficiently than (2) -- see
"xlwt" below.
>Is pyExcelerator being developed any longer? My attempts to reach the
developer have gone nowhere.
(1) There seems to be sporadic activity on the pyExcelerator sourceforge
site.

(2) I am maintaining xlwt (i.e. Excel write), a fork of pyExcelerator --
fixed known and unknown bugs, improved performance, and made it run
under Python 2.3. Available from
https://secure.simplistix.co.uk/svn/xlwt/trunk

See also http://groups.google.com/group/python-excel
>>
w =pyExcelerator.Workbook()
ws = w.add_sheet(fn + p)
for i,d in enumerate(dateList):
ws.write(i+1, 0, dateList[i])
ws.write(i+1, 1, posVals[i])
ws.write(i+1, 2, negVals[i])
w.save(fn+'.xls')

Try using this patch on Cell.py and see if it fixes your problem:

--- Cell.py (revision 4522)
+++ Cell.py (revision 4523)

@@ -101,6 +101,14 @@
def get_biff_data(self):
+ return BIFFRecords.NumberRecord(self.__parent.get_index() ,
self.__idx, self.__xf_idx, self.__number).get()
+ # Skipping all the logic below.
+ # From what I understand it tries to save space.
+ # Unfortunately it gets it wrong and produces false results.
+ # For example:
+ # 814289000 gets written out as -259452824
+

Cheers,
John
May 20 '07 #3

P: n/a
John,

I'd be delighted to try xlwt (does it work under Python 2.4 and 2.5?)
I followed the link to ...svn/xlwt/trunk and found a collection of
files, but no Windows installer. How do I install xlwt?

Thanks in advance

Thomas Philips
May 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.