pyExcelerator bug?

John Machin sjmachin at lexicon.net
Sun May 20 17:58:26 EDT 2007


On 21/05/2007 7:01 AM, Waldemar Osuch wrote:
> On May 16, 4:42 pm, tkp... at 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





More information about the Python-list mailing list