read_table, ncols=2, colkeys=None, dstype=<class ''>)[source] [edit on github]

Create a dataset from a tabular file.

The supported file types (e.g. ASCII or FITS) depends on the selected I/O backend.

  • arg – The name of the file or a representation of the file (the type depends on the I/O backend).

  • ncols (int, optional) – The first ncols columns are read from the file.

  • colkeys (None or list of strings, optional) – If given, select these columns from the file.

  • dstype (optional) – The data type to create (it is expected to follow the interface).



Return type

a derived object

See also



The following examples do not contain argument types specific to a particular I/O backend.

Create a object from the first two columns in the file src.fits:

>>> d = read_table('src.fits')

Create a object from the first three columns in the file src.fits:

>>> d = read_table('src.fits', ncols=3, dstype=Data1DInt)

Create a data set from the specified columns in tbl.fits, where WLEN is used for the independent axis, FLUX the dependent axis, and FLUXERR for the statistical error on the dependent axis:

>>> d = read_table('tbl.fits', colkeys=['WLEN', 'FLUX', 'FLUXERR'])