[AstroPy] ascii.read() OverflowError: Python int too large to convert to C long

Eduardo Bañados Torres eebanado at uc.cl
Wed Apr 24 03:50:43 EDT 2013


Hi all,

I am reading a text file with many columns. The first one is the obj_id
which is a long integer. When I try to open the file with ascii.read() I
get
OverflowError: Python int too large to convert to C long

while doing the same with numpy.loadtxt I don't get the error but the
integer is converted to a float (which would be fine with me)

Does anyone know how can I workaround this in astropy? I would like to work
with astropy

Thanks!

Here is a minimal self-content example:

-----------------------------
from astropy.io import ascii
from StringIO import StringIO

d = StringIO("obj_id x y \n4905757000345846002 21 72\n4905757000345846003
35 58")
#In the following line I get the error
c = ascii.read(d)

#now using numpy
import numpy as np
cn = np.loadtxt(d, skiprows=1)
print cn.T[0]
#check
print cn.T[0][0] == 4905757000345846002
#True
---------------------------------------------
-- 
Eduardo Bañados
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20130424/75aecf2e/attachment.html>


More information about the AstroPy mailing list