Skip to main content
`Ctrl`+`K`

# RST

class astropy.io.ascii.RST(header_rows=None)

  Bases: `FixedWidth`

  reStructuredText simple format table.

  See: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#simple-tables

  Example:

      >>> from astropy.table import QTable
      >>> import astropy.units as u
      >>> import sys
      >>> tbl = QTable({"wave": [350, 950] * u.nm, "response": [0.7, 1.2] * u.count})
      >>> tbl.write(sys.stdout,  format="ascii.rst")
      ===== ========
       wave response
      ===== ========
      350.0      0.7
      950.0      1.2
      ===== ========

  Like other fixed-width formats, when writing a table you can provide `header_rows` to specify a list of table rows to output as the header. For example:

      >>> tbl.write(sys.stdout,  format="ascii.rst", header_rows=['name', 'unit'])
      ===== ========
       wave response
         nm       ct
      ===== ========
      350.0      0.7
      950.0      1.2
      ===== ========

  Currently there is no support for reading tables which utilize continuation lines, or for ones which define column spans through the use of an additional line of dashes in the header.

  Methods Summary

  `read`(table) | Read the `table` and return the results in a format determined by the `outputter` attribute.
  `write`(lines) | Write `table` as list of strings.

  Methods Documentation

  read(table)

    Read the `table` and return the results in a format determined by the `outputter` attribute.

    The `table` parameter is any string or object that can be processed by the instance `inputter`. For the base Inputter class `table` can be one of:

    - File name

    - File-like object

    - String (newline separated) with all header and data lines (must have at least 2 lines)

    - List of strings

    Parameters:
      table `python:str`, python:file-like object, `python:list`

        Input table.

    Returns:
      table `Table`

        Output table

  write(lines)

    Write `table` as list of strings.

    Parameters:
      table `Table`

        Input table data.

    Returns:
      lines `python:list`

        List of strings corresponding to ASCII table