[Numpy-discussion] Problem with loadtxt
Warren Weckesser
warren.weckesser at enthought.com
Wed Aug 18 18:52:45 EDT 2010
Scott MacDonald wrote:
> Yes it should, sorry I must have copied and pasted wrong.
>
> I did some more research and found this bug report:
>
> http://projects.scipy.org/numpy/ticket/1163
>
> I guess this is still open? I am using numpy 1.4.1
>
>
According to that ticket, it is doing int(float(x)) when the dtype is a
subclass of int. This allows it to handle text like "123.45" or "1e4"
properly; passing either of those directly to int() will raise a ValueError.
Perhaps something like this would work for int dtypes:
try:
value = int(text)
except ValueError:
value = int(float(text))
Warren
>
> On Wed, Aug 18, 2010 at 2:42 PM, Friedrich Romstedt
> <friedrichromstedt at gmail.com <mailto:friedrichromstedt at gmail.com>> wrote:
>
> 2010/8/18 Scott MacDonald <scott.p.macdonald at gmail.com
> <mailto:scott.p.macdonald at gmail.com>>:
> > In [42]: c = StringIO("5399354557888517120")
>
> Well, should't it be StringIO("5399354557888517312")? Maybe I'm
> missing sth.
>
> Friedrich
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org <mailto:NumPy-Discussion at scipy.org>
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list