astropy/astropy — pull request #3189 by hamogu (2014-12-17 12:12:06+00:00)
Title: io.registry: '.csv' is not longer sufficient to select reader.

It used to be that reading a csv table with `Table.read()` would not require a format keyword, because the file type is unambiguous. However, that's not longer true:
```
Gabriel = Table.read('finaloutput2010201.csv')

---------------------------------------------------------------------------
Exception Traceback (most recent call last)
in ()
----> 1 Gabriel = Table.read('/data/hguenther/TWHya/H2lines/finaloutput2010201.csv')

/data/guenther/anaconda/lib/python2.7/site-packages/astropy-1.0.dev10102-py2.7-linux-x86_64.egg/astropy/table/table.pyc in read(cls, *args, **kwargs)
1710 passed through to the underlying data reader (e.g. `~astropy.io.ascii.read`).
1711 """
-> 1712 return io_registry.read(cls, *args, **kwargs)
1713
1714 def write(self, *args, **kwargs):

/data/guenther/anaconda/lib/python2.7/site-packages/astropy-1.0.dev10102-py2.7-linux-x86_64.egg/astropy/io/registry.pyc in read(cls, *args, **kwargs)
325
326 format = _get_valid_format(
--> 327 'read', cls, path, fileobj, args, kwargs)
328
329 reader = get_reader(format, cls)

/data/guenther/anaconda/lib/python2.7/site-packages/astropy-1.0.dev10102-py2.7-linux-x86_64.egg/astropy/io/registry.pyc in _get_valid_format(mode, cls, path, fileobj, args, kwargs)
414 raise Exception(
415 "Format is ambiguous - options are: {0}".format(
--> 416 ', '.join(sorted(valid_formats, key=lambda tup: tup[0]))))
417
418 return valid_formats[0]

Exception: Format is ambiguous - options are: ascii.csv, ascii.fast_csv
```

because we now have two `csv` readers. I liked the old, easier way, but I understand that we offer more options now.

@taldcroft : Is this a feature to make people aware of the new fast readers or an unintended site effect?

I think the Exception is handeled very well and the error mesage is helpful - I just wonder if a `csv` should automatically try `ascii.fast_csv` first and `ascii.csv` second if it fails.
Is it even possible to have a csv file that can be read by `ascii.csv` but not by `ascii.fast_csv` if no other special keywords ae given?
For csv files that's probably the most common case. I don't see pople passing in their own HeaderSplitters etc. for csv files, at most they'll skip a couple of lines with `data_start` and `header_start`.