/sphinx_csv_filter

A CSV filter directive for docutils and Sphinx, that extends the "csv-table" reStructuredText directive to add row filtering options.

Primary LanguagePythonApache License 2.0Apache-2.0

Sphinx CSV filter

CI outcome Test suite code coverage Supported Python versions Package version on PyPI PyPI downloads per month Project status (alpha, beta, stable) License

A CSV filter directive for docutils and Sphinx, that extends the "csv-table" reStructuredText directive to add row filtering options.

Details

The package depends on docutils, it provides a CSVFilterDirective, extending CSVTable. When used as a Sphinx extension, it will register the csv-filter Sphinx directive.

Installation

The Sphinx CSV filter plugin is available as a pip package.

To install, run:

$ pip install sphinx-csv-filter

To update, run:

$ pip install -U sphinx-csv-filter

Set Up

To include the extension, add this line to config.py in your Sphinx project:

extensions = ['crate.sphinx.csv']

If you're using other extensions, edit the existing list, or add this:

extensions.append('crate.sphinx.csv')

Use

This plugin adds the following options to the csv-table directive:

:included_cols:
This is a comma-separated list of column indexes to include in the output.
:include:
This option takes a Python dict specifying the column index (starting at zero) and a regular expression. Rows are included if the columnar value matches the supplied regular expression.
:exclude:
This option takes a Python dict specifying the column index (starting at zero) and a regular expression. Rows are excluded if the columnar value matches the supplied regular expression.

If a row matches an :include: as well as an :exclude: filter, the row with be excluded.

Here's an example:

.. csv-filter:: Example Table
   :header: Company,Contact,Country,Attend?
   :file: example.csv
   :exclude: {3: '(?i)Y\w*'}

In this example, rows from example.csv will be omitted from the output if the regular expression (?i)Y\w* matches value of the Attend? column.

Contributing

This project is primarily maintained by Crate.IO, but we welcome community contributions!

See the developer docs and the contribution docs for more information.

Help

Looking for more help?