CSV table

The csv table directive can be used to create a table from comma-separated values (CSV).

Description

The directive selection consists of an explicit markup start (".. ") followed by the type of directive (csv table) and two colons.

(See also: Directives)

Principle

.. csv-table::

Properties

  • A blank line is required between the directive and a preceding text body element (for example, a paragraph with text).

Options

The row block can optionally contain a flat list of table options. The following options are recognized:

widths : integer [integer...]

weighting of column widths

A list of relative column widths separated by commas or spaces. By default, the columns have the same width (100%/#columns).

header rows : integer

header table

The number of rows to be used as table header. Default value is 0.

stub columns : integer

header column table

The number of table columns to be used as table header. Default value is 0.

header : CSV data

Additional data for the table header that is added independently of and before each header line.

Sample

The following sample shows a header table with four columns and two rows.
(In sample project: B_DocuElements\Tables\FB_Libdoc_CSVTable)

(*
.. csv-table:: Property list
   :header: "Items", "Property 1", "Property 2", "Property 3"
   :widths: 10, 15, 15, 15

   "Item 1", 1.67, angular, red
   "Item 2", "not specified", round, blue
*)

or

(*
.. csv-table:: Property list
   :header-rows: 1
   :widths: 10, 15, 15, 15

   "Items", "Property 1", "Property 2", "Property 3"
   "Item 1", 1.67, angular, red
   "Item 2", "not specified", round, blue
*)

CSV table 1: