[Numpy-discussion] long integers in genfromtxt

josef.pktd@gmai... josef.pktd@gmai...
Mon Mar 15 11:34:31 CDT 2010


On Mon, Mar 15, 2010 at 11:25 AM, Bruce Southey <bsouthey@gmail.com> wrote:
> On 03/15/2010 11:06 AM, Pierre GM wrote:
>> On Mar 13, 2010, at 3:51 PM, josef.pktd@gmail.com wrote:
>>
>>> I was trying to find out what the "helpful" message
>>> "TypeError: expected a readable buffer object"  means
>>>
>>> and it seems genfromtxt has problems identifying long integers (at
>>> least on Windows 32)
>>>
>>>
>>>>>> np.array(4160680000,int)
>>>>>>
>>> Traceback (most recent call last):
>>>   File "<pyshell#4>", line 1, in<module>
>>>     np.array(4160680000,int)
>>> OverflowError: long int too large to convert to int
>>>
>>>
>>
>> That's likely a bug.
>> Please open a ticket and and allocate it to me.
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
> Hi,
> I thought this is a MS windows limitation of only supporting 4 byte
> integers.

at least a helpful error message would be useful

int64 works (once I know what the problem is)

>>> np.array(4160680000,np.int64)
array(4160680000L, dtype=int64)

>>> dt= [('','S10'),('',float),('',float),('',float),('',float),('',np.int64),('',float)]
>>> sh = StringIO(s)
>>> data = np.genfromtxt(sh, delimiter=",", dtype=dt, names=True)
>>> data
array([ ('2010-02-12', 1075.95, 1077.8099999999999, 1062.97, 1075.51,
4160680000L, 1075.51),
       ('2010-02-11', 1067.0999999999999, 1080.04, 1060.5899999999999,
1078.47, 4400870000L, 1078.47)],
      dtype=[('Date', '|S10'), ('Open', '<f8'), ('High', '<f8'),
('Low', '<f8'), ('Close', '<f8'), ('Volume', '<i8'), ('Adj_Close',
'<f8')])
>>>

Thanks Pierre, http://projects.scipy.org/numpy/ticket/1428

Josef


>
> Bruce
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list