Including a CSV file

include reads the table from a file, relative to the directory pandoc runs in, instead of the code block, which can be empty:

Fruits, from fruits.csv
Fruit Price Number
Bananas $1.34 12
Oranges $2.10 5

The options are read from the YAML block only, as with any other table, and not from attributes on the code block such as {.table include="fruits.csv" caption="..."}.

include-encoding sets the file’s encoding when it is not UTF-8. A CSV file saved by Microsoft Excel may need utf-8-sig.

csv-kwargs is passed to Python’s csv.reader, here to read semicolon-separated values:

Fruit Price
Bananas 1,34
Oranges 2,10

Here, for values in single quotes, after a comma and a space:

Prefix City Comment
030 Berlin My comment
069 Frankfurt Main, not Oder

Source

This page is made from the Markdown below. The second tab is what pandoc -F pantable -t markdown writes for it, each table as a pandoc table; the third converts those tables back to code blocks with pantable2csvx.

---
title: Including a CSV file
---

`include` reads the table from a file, relative to the directory pandoc
runs in, instead of the code block, which can be empty:

```table
---
caption: Fruits, from fruits.csv
include: fruits.csv
---
```

The options are read from the YAML block only, as with any other
table, and not from attributes on the code block such as
`{.table include="fruits.csv" caption="..."}`.

`include-encoding` sets the file's encoding when it is not UTF-8. A CSV
file saved by Microsoft Excel may need `utf-8-sig`.

`csv-kwargs` is passed to Python's
[`csv.reader`](https://docs.python.org/3/library/csv.html#csv.reader),
here to read semicolon-separated values:

```table
---
csv-kwargs:
  delimiter: ;
---
Fruit;Price
Bananas;1,34
Oranges;2,10
```

Here, for values in single quotes, after a comma and a space:

```table
---
csv-kwargs:
  quotechar: "'"
  skipinitialspace: true
---
Prefix, City, Comment
'030', 'Berlin', 'My comment'
'069', 'Frankfurt', 'Main, not Oder'
```
`include` reads the table from a file, relative to the directory pandoc
runs in, instead of the code block, which can be empty:

  Fruit     Price    Number
  --------- -------- --------
  Bananas   \$1.34   12
  Oranges   \$2.10   5

  : Fruits, from fruits.csv

The options are read from the YAML block only, as with any other table,
and not from attributes on the code block such as
`{.table include="fruits.csv" caption="..."}`.

`include-encoding` sets the file's encoding when it is not UTF-8. A CSV
file saved by Microsoft Excel may need `utf-8-sig`.

`csv-kwargs` is passed to Python's
[`csv.reader`](https://docs.python.org/3/library/csv.html#csv.reader),
here to read semicolon-separated values:

  Fruit     Price
  --------- -------
  Bananas   1,34
  Oranges   2,10

  : 

Here, for values in single quotes, after a comma and a space:

  Prefix   City        Comment
  -------- ----------- ----------------
  030      Berlin      My comment
  069      Frankfurt   Main, not Oder

  :
`include` reads the table from a file, relative to the directory pandoc
runs in, instead of the code block, which can be empty:

``` table
---
caption: Fruits, from fruits.csv
fancy-table: true
markdown: true
...
===,Fruit,Price,Number

,Bananas,\$1.34,12

___,Oranges,\$2.10,5

```

The options are read from the YAML block only, as with any other table,
and not from attributes on the code block such as
`{.table include="fruits.csv" caption="..."}`.

`include-encoding` sets the file's encoding when it is not UTF-8. A CSV
file saved by Microsoft Excel may need `utf-8-sig`.

`csv-kwargs` is passed to Python's
[`csv.reader`](https://docs.python.org/3/library/csv.html#csv.reader),
here to read semicolon-separated values:

``` table
---
fancy-table: true
markdown: true
...
===,Fruit,Price

,Bananas,"1,34"
___,Oranges,"2,10"
```

Here, for values in single quotes, after a comma and a space:

``` table
---
fancy-table: true
markdown: true
...
===,Prefix,City,Comment

,030,Berlin,My comment

___,069,Frankfurt,"Main, not Oder"
```