Skip to content

File data

Giorgio Garofalo edited this page Dec 11, 2025 · 10 revisions

Quarkdown offers functions to retrieve information from files.

Note

The following functions refer to a path parameter, which accepts the path to the target file, which may be relative to the location of the main source file, or absolute.
A slash (/) is the global path separator, agnostic to the current file system in use.

File text content

The .read {path} function returns the string content of the given file.

An optional lines parameter of type Range is also supported, which allows for the selection of a specific range of lines (inclusive, starting from 1). An invalid or out of bounds range causes an error.
If no range is provided, the whole file is read.

.read {myfile.txt} lines:{3..8}

The strategy used for open ranges is defined as follows:

  • If the range is open on the left end (..N) it starts reading from the beginning of the file until line N.
  • If the range is open on the right end (N..) it reads from line N to the end of the file.
  • If the range is open on both ends (..) the whole file is read.

Tip

.read can be particularly useful when used in combination with .code and .mermaid in order to load code snippets from external files:

.code {java}
  .read {Point.java}

Listing files in a directory

The .listfiles {path} {sortby?} {order?}[docs] function returns an iterable of the files in a directory. It's unordered by default, or can be sorted by name or date.

As any other collection, the result can be iterated upon, or supplied to other functions. For example, it's possible to perform automatic bulk inclusions via .includeall:

.includeall {.listfiles {somedirectory} sortby:{name}}

Getting a file name

The .filename {path} {extension?}[docs] function returns the file name from a given file path. The optional extension boolean parameter controls whether the file extension is included in the result.

.filename {path/to/myfile.txt} extension:{false}

Output: myfile

Table from CSV

The .csv {path} {mode?} {caption?}[docs] function loads a table from a CSV file. The first row of the CSV file is always used as the header row.

Tables loaded from CSV can also be manipulated: see Table manipulation for more.

.csv {people.csv}

The mode parameter controls how the CSV file is parsed. It defaults to plain, which treats all cell content as plain text. If set to markdown, cell content is parsed as inline Quarkdown source code, allowing for formatting, rich content, and even inline function calls inside CSV.

Name,  Favorite drink, Age *(as of 2026)*
Alice, Coffee,         .subtract {2026} {1995}
Bob,   *Pepsi*,        .subtract {2026} {2001}

A caption can also be provided:

.csv {people.csv} caption:{People data.}

Getting started [NEW!]

Documentation

CLI tools

Markdown enhancements

Functions

Setting up

Multi-file projects

Layout

Charts & diagrams

Scripting & control flow

Utilities

Slides

I/O

Native content

Value types

Built-in libraries

  • Paper: abstract, definitions, theorems, and more

Extra features

Inside Quarkdown

Clone this wiki locally