Skip to main content

Actions Status PyPI - Python Version PyPI PyPI - Downloads codecov GitHub contributors PyPI - License

mkdocs-table-reader-plugin

MkDocs plugin that adds a {{ read_csv('table.csv') }} markdown tag to directly insert CSV files as a table into a page. See it in action at timvink.github.io/mkdocs-table-reader-plugin/.

This makes it easier to build reproducible reports. For more complex use cases, consider mknotebooks, mkdocs-markdownextradata-plugin or mkdocs-macros-plugin.

Setup

Install the plugin using pip3:

pip3 install mkdocs-table-reader-plugin

Next, add the following lines to your mkdocs.yml:

plugins:
  - search
  - table-reader

If you have no plugins entry in your config file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set.

Usage

In your markdown documents you can now use:

{{ read_csv('path_to_table.csv') }}

Where the path is relative to the location of your project's mkdocs.yml file.

Under the hood this is basically:

import pandas as pd
df = pd.read_csv('path_to_table.csv')
df.to_markdown(index=False, tablefmt='pipe')

Which means you can pass all parameters of pandas.read_csv().

You can see an example usage in this repo (see mkdocs.yml and docs/) and the result at timvink.github.io/mkdocs-table-reader-plugin/.

Available readers

The following table reader functions are available:

Reading xlsx files

You might get a XLRDError('Excel xlsx file; not supported',) error when trying to read modern excel files. That's because xlrd does not support .xlsx files (stackoverflow post). Instead, install openpyxl and use:

{{ read_excel('tables/excel_table.xlsx', engine='openpyxl') }}

Reading yaml variables

mkdocs-markdownextradata-plugin is a great plugin to use when working with yaml files. It will read in all yaml files in a specified directory and make all keys available as jinja2 variables.

Options

You can customize the plugin by setting options in mkdocs.yml. For example:

plugins:
  - table-reader:
      data_path: "docs"

data_path

Default is ., which means you can specify the path to your table files relative to the location of your project's mkdocs.yml file. If you use a folder for all your table files you can shorten the path specification by setting data_path.

For example, if you set data_path to docs/ in the project below, you will be able to use {{ read_csv("basic_table.csv") }} instead of {{ read_csv("docs/basic_table.csv") }} inside index.md.

.
├── docs
│   ├── basic_table.csv
│   └── index.md
└── mkdocs.yml

Contributing

Contributions are very welcome! Please read CONTRIBUTING.md before putting in any work.

Metadata

Release files for mkdocs-table-reader-plugin 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-table-reader-plugin 0.5
File Size Uploaded
mkdocs-table-reader-plugin-0.5.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-table-reader-plugin 0.5
File Interpreter ABI Platform
mkdocs_table_reader_plugin-0.5-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / mkdocs-table-reader-plugin-0.5.tar.gz

Download URL mkdocs-table-reader-plugin-0.5.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4ef3f296199c8ac3c7f5be462801ba0e4a2606dc2d3c92ebc11f5b5af77103cd
BLAKE2b-256 checksum
How to use checksums
4fccf0289f79daa84f7a2bbcaaaa39553c7fd294a3be29f4027c24d4ec1eea81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / mkdocs_table_reader_plugin-0.5-py3-none-any.whl

Download URL mkdocs_table_reader_plugin-0.5-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
721d79615242e4c882bac4326258301b9aa496de9db3277a511e15f6a2899767
BLAKE2b-256 checksum
How to use checksums
2df1df9a52ebce59117ebd6cd8da49e084ecafe144e1def2d3ce7261da8ce057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release history Release notifications | RSS feed

4.0.1

2 release files

4.0.0

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0

2 release files

1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6

2 release files

This release

0.5 This release

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page