pyExcelerator big integer values
I use pyExcelerator to import some data from xml file. One column contains integer values like: 4750456000708 4750456000715 4750456000333 ... But when I do import the pyExcelerator converts them to something like this: 4.7504560002e+12 4.7504560007e+12 4.7504560007e+12 4.7504560003e+12 How I understand it's because the integer value is too big. If the type of the items was string, then all would be fine, but I can't control the file content. The question is, how can I import the integers in normal format. -- http://mail.python.org/mailman/listinfo/python-list
Re: pyExcelerator big integer values
Thank you, the repr() function helped me a lot.
v = unicode(values[(row_idx, col_idx)])
if v.endswith('e+12'):
v = repr(values[(row_idx, col_idx)])
--
http://mail.python.org/mailman/listinfo/python-list
Re: pyExcelerator big integer values
John Machin wrote:
> Here's a possible replacement -- I say possible because you have been
> rather coy about what you are actually trying to do.
>
> value = values[(row_idx, col_idx)])
> if isinstance(value, float):
> v = repr(value)
> else:
> v = unicode(value)
>
> HTH
> John
My final result:
value = values[(row_idx, col_idx)]
if isinstance(value, float) and
re.match('^\d+\.\d+e\+\d+$',unicode(value)):
v = repr(value)
else:
v = unicode(value)
--
http://mail.python.org/mailman/listinfo/python-list
