I would like to thank Johannes Sahlmann who pointed me out the solution
(off-list I think)
For completeness, this solves the problem:
from astropy.io import ascii
from StringIO import StringIO
d = StringIO("obj_id x y \n4905757000345846002 21 72\n4905757000345846003
35 58")
converter = {'obj_id':[ascii.convert_numpy(np.int64)]}
c = ascii.read(d, converters=converter)
print c
Thanks again,
On Wed, Apr 24, 2013 at 9:50 AM, Eduardo Bañados Torres <eebanado@uc.cl>wrote:
> 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
>
--
Eduardo Bañados
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/astropy/attachments/20130424/18a23f22/attachment.html