Custom Directives v0.1 documentation

CSVF Table

The csvftable directive is the same as csvtable except that the columns and their order to be displayed can be specified by a columns parameter.

Directive-Type:csvftable
Doctree Element:
 table
Directive Arguments:
 1,optional (table title)
Directive Options:
 Possible
Directive Content:
 A CSV (comma-separated values) table

The following options (in addtion to the standard csv-table directives) are recognized:

columns: integer[ integer ...]
A comma- or space-separated list of columns to include in the rendered output. The columns are numbered from left to right, starting with “1” for the left-most column in the CSV source. Default is to include all columns in the order they appear in the CSV source.

Example

Given the csv file:

"Name","Age","Folly","Date"
"Harry",12,"Eating worms","2009-07-15"
"Jane",14,"Running fast","2010-01-11"
"Bob",48,"Driving range","1998-08-21"
"Sue",32,"Epicurial facilitation","2011-04-15"
"Rene",36,"Speed","2009-07-12"

We can use the csvftable directive to render only a portion of the table and specify the ordering of columns. For example:

.. csvftable:: Example of CSVF table
   :header-rows: 1
   :widths: 10 10 20
   :columns: 1 2 3
   :file: csv-data/example.csv

renders as:

Example of CSVF table
Name Age Folly
Harry 12 Eating worms
Jane 14 Running fast
Bob 48 Driving range
Sue 32 Epicurial facilitation
Rene 36 Speed

and:

.. csvftable:: Example of CSVF table
   :header-rows: 1
   :widths: 20 10 10 10
   :columns: 3 2 1 4
   :file: csv-data/example.csv

renders as:

Example of CSVF table
Folly Age Name Date
Eating worms 12 Harry 2009-07-15
Running fast 14 Jane 2010-01-11
Driving range 48 Bob 1998-08-21
Epicurial facilitation 32 Sue 2011-04-15
Speed 36 Rene 2009-07-12

Module

Implements the CSVFTable docutils directive.

License
This work was created by participants in the DataONE project, and is
jointly copyrighted by participating institutions in DataONE. For
more information on DataONE, see our web site at http://dataone.org.

  Copyright 2010

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class csvftable.CSVFTable(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Extends docutils csvtable by adding a columns parameter to specify which columns from the data source are to be rendered.

get_columns()
parse_csv_data_into_rows(csv_data, dialect, source)