You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems genfromtxt has problems identifying long integers (at
least on Windows 32)
I have a csv file with large integers:
>>> 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
genfromtxt fails with non-informative exception
>>> s = '''Date,Open,High,Low,Close,Volume,Adj Close
... 2010-02-12,1075.95,1077.81,1062.97,1075.51,4160680000,1075.51
... 2010-02-11,1067.10,1080.04,1060.59,1078.47,4400870000,1078.47'''
>>> sh = StringIO(s)
>>> data = np.genfromtxt(sh, delimiter=",", dtype=None, names=True)
Traceback (most recent call last):
File "C:\Programs\Python25\Lib\site-packages\numpy\lib\io.py", line
1367, in genfromtxt
output = np.array(data, dtype=ddtype)
TypeError: expected a readable buffer object
same with explicit dtypes using int for the long integer
>>> dt= [(_,'S10'),(_,float),(_,float),(_,float),(_,float),(_,int),('',float)]
>>> sh = StringIO(s)
>>> data = np.genfromtxt(sh, delimiter=",", dtype=dt, names=True)
Traceback (most recent call last):
File "C:\Programs\Python25\Lib\site-packages\numpy\lib\io.py", line
1388, in genfromtxt
rows = np.array(data, dtype=[('', _) for _ in dtype_flat])
TypeError: expected a readable buffer object
It seems genfromtxt has problems identifying long integers (at
least on Windows 32)
I can confirm this is also happening on a Debian box with numpy 1.4.1, although an integer larger than the first example is needed to trigger a long int (e.g., 10000000000000000000).
You can now fix this by explicitly specifying int64 or uint64. Floats will raise errors if those types are specified and the automatic detection case will still fail. I suppose this could all be fixed up a bit more but that would require considerably more work.
Original ticket http://projects.scipy.org/numpy/ticket/1428 on 2010-03-15 by @josef-pkt, assigned to unknown.
It seems genfromtxt has problems identifying long integers (at
least on Windows 32)
I have a csv file with large integers:
genfromtxt fails with non-informative exception
same with explicit dtypes using int for the long integer
using float works:
The text was updated successfully, but these errors were encountered: