Skip to content

Readers

The following table reader functions are available:

read_csv

{{ read_csv() }} passed to pandas.read_csv(). Example:

{{ read_csv('tables/basic_table.csv') }}

a b
40 73
50 52
531456.123 80
name table1

read_fwf

{{ read_fwf() }} passed to pandas.read_fwf(). Example:

{{ read_fwf('tables/fixedwidth_table.txt') }}

Brand Price
Honda Civic 22001
Toyota Corolla 25000
Ford Focus 27000
Audi A4 35000

read_yaml

{{ read_yaml() }} is parsed with yaml.safe_load() and passed to pandas.json_normalize(). Example:

{{ read_yaml('tables/yaml_table.yml') }}

a b
40 73
50 52
531456 80
name table1

read_table

{{ read_table() }} passed to pandas.read_table(). Example:

{{ read_table('tables/basic_table.csv', sep = ',') }}

a b
40 73
50 52
531456.123 80
name table1

read_json

{{ read_json() }} passed to pandas.read_json(). Example:

{{ read_json('tables/data.json', orient='split') }}

col 1 col 2
a b
c d

read_feather

{{ read_feather() }} passed to pandas.read_feather(). Example:

{{ read_json('tables/data.feather') }}

col 1 col 2
a b
c d

read_excel

{{ read_excel() }} passed to pandas.read_excel(). Example:

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

a b
40 73
50 52
531456 8

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') }}

read_raw

{{ read_raw() }} inserts contents from a file directly. This is great if you have a file with a table already in markdown format. It could also replace a workflow where you use the snippets extension to embed external files.

Example:

{{ read_raw('tables/markdown_table.md') }}

Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1