# Cds¶

class astropy.io.ascii.Cds(readme=None)[source]

Read a CDS format table. See http://vizier.u-strasbg.fr/doc/catstd.htx. Example:

Table: Table name here
= ==============================================================================
Catalog reference paper
Bibliography info here
================================================================================
ADC_Keywords: Keyword ; Another keyword ; etc

Description:
Catalog description here.
================================================================================
Byte-by-byte Description of file: datafile3.txt
--------------------------------------------------------------------------------
Bytes Format Units  Label  Explanations
--------------------------------------------------------------------------------
1-  3 I3     ---    Index  Running identification number
5-  6 I2     h      RAh    Hour of Right Ascension (J2000)
8-  9 I2     min    RAm    Minute of Right Ascension (J2000)
11- 15 F5.2   s      RAs    Second of Right Ascension (J2000)
--------------------------------------------------------------------------------
Note (1): A CDS file can contain sections with various metadata.
Notes can be multiple lines.
Note (2): Another note.
--------------------------------------------------------------------------------
1 03 28 39.09
2 04 18 24.11


The CDS format consists of a table description and the table data. These can be in separate files as a ReadMe file plus data file(s), or combined in a single file. Different subsections within the description are separated by lines of dashes or equal signs (“——” or “======”). The table which specifies the column information must be preceded by a line starting with “Byte-by-byte Description of file:”.

In the case where the table description is combined with the data values, the data must be in the last section and must be preceded by a section delimiter line (dashes or equal signs only).

Basic usage

Use the ascii.read() function as normal, with an optional readme parameter indicating the CDS ReadMe file. If not supplied it is assumed that the header information is at the top of the given table. Examples:

>>> from astropy.io import ascii


The table name and the CDS ReadMe file can be entered as URLs. This can be used to directly load tables from the Internet. For example, Vizier tables from the CDS:

>>> table = ascii.read("ftp://cdsarc.u-strasbg.fr/pub/cats/VII/253/snrs.dat",


If the header (ReadMe) and data are stored in a single file and there is content between the header and the data (for instance Notes), then the parsing process may fail. In this case you can instruct the reader to guess the actual start of the data by supplying data_start='guess' in the call to the ascii.read() function. You should verify that the output data table matches expectation based on the input CDS file.

When Cds reader object is created with a readme parameter passed to it at initialization, then when the read method is executed with a table filename, the header information for the specified table is taken from the readme file. An InconsistentTableError is raised if the readme file does not have header information for the given table.

>>> readme = "t/vizier/ReadMe"
>>> # table5.dat has the same ReadMe file


If no readme parameter is specified, then the header information is assumed to be at the top of the given table.

>>> r = ascii.get_reader(ascii.Cds)
>>> #The following gives InconsistentTableError, since no
>>> #readme file was given and table1.dat does not have a header.
Traceback (most recent call last):
...
InconsistentTableError: No CDS section delimiter found


Caveats:

• The Units and Explanations are available in the column unit and description attributes, respectively.
• The other metadata defined by this format is not available in the output table.

Methods Summary

 read(table) write([table]) Not available for the Cds class (raises NotImplementedError)

Methods Documentation

read(table)[source]
write(table=None)[source]

Not available for the Cds class (raises NotImplementedError)