docs-builder
Loading

CSV files

The {csv-include} directive allows you to include and render CSV files as formatted tables in your documentation. The directive automatically parses CSV content and renders it using the standard table styles defined in table.css.

Sample user data from the database
Name Age City Occupation
John Doe 30 New York Software Engineer
Jane Smith 25 Los Angeles Product Manager
Bob Johnson 35 Chicago Data Scientist
Alice Brown 28 San Francisco UX Designer
Charlie Wilson 32 Boston DevOps Engineer
:::{csv-include} _snippets/sample-data.csv
:::

The CSV file directive supports several options to customize the table rendering:

Add a descriptive caption above the table:

:::{csv-include} _snippets/sample-data.csv
:caption: Sample user data from the database
:::

Specify a custom field separator (default is comma):

:::{csv-include} _snippets/sample-data.csv
:separator: ;
:::

The directive includes built-in performance limits to handle large files efficiently:

  • Row limit: Maximum of 25,000 rows will be displayed
  • Column limit: Maximum of 10 columns will be displayed
  • File size limit: Maximum file size of 10MB

The CSV directive is optimized for large files:

  • Files are processed using streaming to avoid loading everything into memory
  • Built-in size validation prevents processing of files that exceed 10MB
  • Row and column limits protect against accidentally rendering massive tables
  • Warning messages are displayed when limits are exceeded

For optimal performance with large CSV files, consider:

  • Breaking very large files into smaller, more manageable chunks