473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PyExcelerator

I write data to Excel files using PyExcelerator 0.6.3.a and have done
so successfully for small files (10-15 cells). I'm experiencing an
error when writing a big chunk of data (10,000 cells) to Excel. By way
of comparison, the same data writes perfectly well to a csv file using
Python's built in csv module. I run the program in PyScripter, and the
traceback shows the following sequence of calls:

main (my routine)
writeData (my routine)
save Line 563
get_biff_data Line 548
get_biff_data Line 1357
__row_blocks_rec Line 1276
get_cells_biff_data Line 200
get_biff_data Line 106

SystemError: frexp() result out of range

The line it stops at in get_biff_data is the line that starts with
packed =

def get_biff_data(self):
rk_encoded = 0

packed = struct.pack('<d', self.__number)

Any thoughts on what the problem could be?

Sincerely
Thomas Philips

Jun 2 '06 #1
1 3213
On 3/06/2006 3:39 AM, tk****@hotmail.com wrote:
I write data to Excel files using PyExcelerator 0.6.3.a and have done
so successfully for small files (10-15 cells). I'm experiencing an
error when writing a big chunk of data (10,000 cells) to Excel. By way
of comparison, the same data writes perfectly well to a csv file using
Python's built in csv module. I run the program in PyScripter, and the
traceback shows the following sequence of calls:

main (my routine)
writeData (my routine)
save Line 563
get_biff_data Line 548
get_biff_data Line 1357
__row_blocks_rec Line 1276
get_cells_biff_data Line 200
get_biff_data Line 106
Grumble: When you need to post a traceback, please supply one that shows
on each line which *file* the source line is in. In this case there are
multiple files, and 9 classes spread over 4 files have a method called
get_biff_data.

SystemError: frexp() result out of range

The line it stops at in get_biff_data is the line that starts with
packed =

def get_biff_data(self):
rk_encoded = 0

packed = struct.pack('<d', self.__number)

Any thoughts on what the problem could be?


It is calling struct.pack (see structmodule.c in the Python source) to
encode one of your cell values as an 8-byte little-endian IEEE 754
floating-point number. This task is handed off to _PyFloat_Pack8() (see
floatobject.c). Here's the relevant bit:

"""
if (x < 0) {
sign = 1;
x = -x;
}
else
sign = 0;

f = frexp(x, &e);

/* Normalize f to be in the range [1.0, 2.0) */
if (0.5 <= f && f < 1.0) {
f *= 2.0;
e--;
}
else if (f == 0.0)
e = 0;
else {
PyErr_SetString(PyExc_SystemError,
"frexp() result out of range");
return -1;
}
"""
where x is your cell value as a C double.

frexp() is a standard C library routine. The above code is just checking
that it has done its job correctly. AFAICT from reading K&R v2 p251, the
code is correct.

Aside: isn't open source wonderful? Well it is for me. It could be
wonderful for you too :-)

I'm not an IEEE 754 guru by any means, so I'm guessing your value could
be an Inf (infinity) or a NaN (not a number) -- there's no explicit test
for those in the code -- or you have stumbled on a value that's a corner
case on your platform. Maybe it's -0.0 (zero with the sign bit set).

Grumble: When you have a problem like this, you should state what
version of Python you are using, on what platform. The line you get when
you run Python at the command line is a start e.g.
"""Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
on win32"""

Please tell us this, plus explicitly what OS and what hardware you are
running on.

OK, now what's this dodgy number?? Unfortunately, the error is happening
right at the end of your process, in the workbook save method. The
only info about which row/column is buried deep in pyExcelerator. We
don't (yet) want to start poking about there ...

Try these steps:
1. Search your alternative CSV output file for the text "Inf" or "NaN"
(case insensitive).
2. Put some code in your cell write routine to filter the values you are
writing:

absval = abs(value)
SMALL = 0.000001 # depends on what is reasonable for your app
LARGE = 10.0 ** 10 # depends ...
if not (value == 0.0 or (SMALL <= absval <= LARGE)):
print "strange value %r in row=%d col=%d" % (value, rownum, colnum)

Then come back and tell us what if anything you've found.

HTH,
John
Jun 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marco Aschwanden | last post by:
Hi, Yesterday I placed a bug report on PyExcelerators-Sourceforge-page... but I am not so sure anymore, whether this is really a bug - I could imagine that I missed something, but I don't see...
3
by: tkpmep | last post by:
I downloaded PyExcelerator.zip as I need to write some data into Excel files, and tried unsuccessfully to install it. I unzipped the files into C:/Python24/Lib/site-packages/PyExcelerator, and in a...
2
by: tkpmep | last post by:
I have just installed PyExcelerator, and now want to use it to read Excel spreadsheets with a variable number of rows and columns and with multiple sheets. Unfortunately, no documentation seems to...
4
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not...
5
by: susan | last post by:
Hi, I'm new of Python, and this problem stucked me whole day but can't be solved. I use python 2.4.3, which is download from cygwin packages. Then I downloaded pyexcelerator-0.5.3a, unzip it, ...
3
by: tkpmep | last post by:
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...
1
by: aneesh.goel.rbtx | last post by:
I'm using pyExcelerator to take a folder of CSV files and create Excel workbooks for all of them, then generate an Excel workbook with the data from all of them. Everything up until here works...
1
by: patrick.waldo | last post by:
Hi all, I was just curious if there was a built-in or a more efficient way to do take multiple rows of information and write them into excel using pyExcelerator. This is how I resolved the...
1
by: A_H | last post by:
Hi, I'm using PyExcelerator, and it's great, but I can't figure out a few things: (1) I set the cell style to '0.00%' but the style does not work. (2) I want to place a border around the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.