astropy/astropy — pull request #2234 by taldcroft (2014-03-25 18:15:51+00:00)
Title: In io.ascii, fall back to string if integers are too large

If I try and read the following file:

```
a b
12121312311248721894712984728 1122
```

using ``Table``, I get:

```
In [5]: t = Table.read('data', format='ascii')
ERROR: OverflowError: Python int too large to convert to C long [astropy.io.ascii.core]
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
in ()
----> 1 t = Table.read('data', format='ascii')

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/table/table.py in read(cls, *args, **kwargs)
1725 passed through to the underlying data reader (e.g. `~astropy.io.ascii.ui.read`).
1726 """
-> 1727 return io_registry.read(cls, *args, **kwargs)
1728
1729 def write(self, *args, **kwargs):

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/registry.py in read(cls, *args, **kwargs)
317
318 reader = get_reader(format, cls)
--> 319 table = reader(*args, **kwargs)
320
321 if not isinstance(table, cls):

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/connect.py in read_asciitable(filename, **kwargs)
19 def read_asciitable(filename, **kwargs):
20 from .ui import read
---> 21 return read(filename, **kwargs)
22
23 io_registry.register_reader('ascii', Table, read_asciitable)

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/ui.py in read(table, guess, **kwargs)
154 guess = _GUESS
155 if guess:
--> 156 dat = _guess(table, new_kwargs)
157 else:
158 reader = get_reader(**new_kwargs)

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/ui.py in _guess(table, read_kwargs)
196
197 reader = get_reader(**guess_kwargs)
--> 198 dat = reader.read(table)
199
200 # When guessing require at least two columns

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/core.py in read(self, table)
851
852 self.data.masks(cols)
--> 853 table = self.outputter(cols, self.meta)
854 self.cols = self.header.cols
855

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/core.py in __call__(self, cols, meta)
649
650 def __call__(self, cols, meta):
--> 651 self._convert_vals(cols)
652
653 # If there are any values that were filled and tagged with a mask bit then this

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/core.py in _convert_vals(self, cols)
631 if not issubclass(converter_type, col.type):
632 raise TypeError()
--> 633 col.data = converter_func(col.str_vals)
634 col.type = converter_type
635 except (TypeError, ValueError):

/Volumes/Raptor/Library/Python/3.3/lib/python/site-packages/astropy-0.4.dev7437-py3.3-macosx-10.8-x86_64.egg/astropy/io/ascii/core.py in converter(vals)
590
591 def converter(vals):
--> 592 return numpy.array(vals, numpy_type)
593 return converter, converter_type
594

OverflowError: Python int too large to convert to C long
```

Maybe when the integers are too large, strings should be used instead? This is a simplified version from the issue described in http://stackoverflow.com/questions/22617428/overflowerror-python-int-too-large-to-convert-to-c-long-with-astropy-table.