RST#
- class astropy.io.ascii.RST(header_rows=None)[source]#
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 theoutputter
attribute.write
(lines)Write
table
as list of strings.Methods Documentation
- read(table)[source]#
Read the
table
and return the results in a format determined by theoutputter
attribute.The
table
parameter is any string or object that can be processed by the instanceinputter
. For the base Inputter classtable
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
str
, file-like object,list
Input table.
- table
- Returns:
- table
Table
Output table
- table