.docname {File data}
.include {docs}

Quarkdown provides functions to retrieve information from files.

> [!NOTE]
> The following functions accept a `path` parameter, which can be either a path relative to the main source file's location or an absolute path. Use a slash (`/`) as the path separator, regardless of the operating system.

## File text content

The **`.read {path}`** .docslink {quarkdown-stdlib/com.quarkdown.stdlib.module.Data/read.html} function returns the string content of the specified file.

An optional `lines` parameter of type [`Range`](range.qd) selects a specific range of lines (inclusive, starting from 1). An invalid or out-of-bounds range causes an error. If you do not provide a range, Quarkdown reads the entire file.

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

Open ranges work as follows:

- If the range is open on the left end (`..N`), Quarkdown reads from the beginning of the file to line `N`.
- If the range is open on the right end (`N..`), Quarkdown reads from line `N` to the end of the file.
- If the range is open on both ends (`..`), Quarkdown reads the entire file.

.examplemirror {`\.read` is particularly useful in combination with functions such as [`\.code`](code.qd), [`\.mermaid`](mermaid-diagrams.qd) and [`\.css`](css.qd) to load code snippets from external files.}
    .code
        .read {assets/point.ts}

## Getting a file name

The **`.filename {path} {extension?}`** .docslink {quarkdown-stdlib/com.quarkdown.stdlib.module.Data/filename.html} 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.

.examplemirror
    .filename {assets/point.ts} extension:{no}

This can be particularly useful when combined with [`.listfiles`](listing-files.qd).

## Table from CSV

The **`.csv {path} {mode?} {caption?}`** .docslink {quarkdown-stdlib/com.quarkdown.stdlib.module.Data/csv.html} function loads a table from a CSV file. The first row of the CSV file always serves as the header row.

Tables loaded from CSV can also be manipulated. See [*Table manipulation*](table-manipulation.qd) for more information.

.examplemirror
    .csv {assets/people.csv}

You can also provide a caption.

.examplemirror
    .csv {assets/people.csv} caption:{People data.}

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`, Quarkdown parses cell content as inline Quarkdown source code, allowing formatting, rich content, and inline function calls within the CSV.

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

.examplemirror
    .csv {assets/people2.csv} mode:{markdown}