Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Copy to the clipboard

y copies a cell, a row, the view, the table or a Python script that rebuilds it to the system clipboard.

In the dialog you pick a scope and a format. It remembers your last choices, so repeating a copy is y Enter.

Copy a table into a note

On Food nutrition (fast food), summarize each chain:

SELECT restaurant, ROUND(AVG(calories), 0) AS avg_calories,
       ROUND(AVG(protein), 1) AS avg_protein, COUNT(*) AS items
FROM df
GROUP BY restaurant
ORDER BY avg_calories DESC
  1. Press y. On Scope, press → until it reads Table.
  2. ↓ to Format, → until it reads Markdown.
  3. Press Enter to copy. The status line says Copied 8 rows as Markdown.

The Copy dialog over the restaurant summary, Scope Table and Format Markdown: Copy all 8 rows as Markdown

The dialog says what Enter copies: all 8 rows. Paste them into a note:

| restaurant  | avg_calories | avg_protein | items |
| ----------- | -----------: | ----------: | ----: |
| Mcdonalds   |        640.0 |        40.3 |    57 |
| Sonic       |        632.0 |        29.2 |    53 |
| Burger King |        609.0 |        30.0 |    70 |
| Arbys       |        533.0 |        29.3 |    55 |
| Dairy Queen |        520.0 |        24.8 |    42 |
| Subway      |        503.0 |        30.3 |    96 |
| Taco Bell   |        444.0 |        17.4 |   115 |
| Chick Fil-A |        384.0 |        31.7 |    27 |

Values are copied raw, so round them in the query. The data spells McDonald’s Mcdonalds.

For a spreadsheet, choose TSV instead. Table includes all matching rows; View includes only the rows on screen.

ScopeWhat it copies
CellThe current row’s value in one column, as plain text. The column is the column cursor’s unless you pick another
RowThe current row
ViewThe rows on screen, with every displayed column
TableEverything in the view, as an export would write it: all rows and columns as queried, filtered and sorted
Python (Polars)The view as a Python script that rebuilds it; see below
FormatDetails
TSVTab-separated, what spreadsheets expect from a paste
CSVComma-separated
MarkdownA pipe table, padded and aligned, numeric columns right-aligned

A TSV or CSV copy to the native clipboard also carries an HTML table, so a paste into a spreadsheet or an email keeps its columns, while a paste into a terminal is plain text.

Values are copied raw, as in an export: display formatting is not applied, a float is copied as stored rather than rounded as on screen, and a null is an empty field. List and struct cells are JSON, as in a CSV export, and a duration is ISO 8601 text such as PT3723.004S. A binary column is base64 in a Table copy. Cell, Row and View copies hold the ‹binary› placeholder, because the screen never reads the bytes.

The Header toggle is on for View and Table and off for Row, and a Markdown table always has its header. The dialog hides Header for the Cell and Python scopes and the Markdown format, and hides Format for the Python scope, since they do not apply there.

To copy one field of the current row, including a hidden or binary one, press Space to inspect the row, move to the field and press y.

A large Table copy asks you to confirm first, counting a binary column at its base64 size. datui learns a binary column’s size from the Parquet footers it reads to open a local directory of Parquet files or a single Parquet object in cloud storage. A copy also asks when its size is not known: the row count is still being read, or no footer gave a binary column’s size, as for a single local file. A copy over 200 MiB is refused, and the message points to export. An osc52 copy asks only when its cap is over 10 MiB, since it never copies more than the cap.

Copy the view as Python

Press y, choose Python (Polars) on Scope and press Enter. The clipboard gets a script that builds the view with Polars:

import polars as pl

df = (
    pl.scan_csv("sales.csv", try_parse_dates=True)
    .filter((pl.col("region") == "north") & (pl.col("qty") > 1))
    .sort(["amount", "order_id"], descending=[True, False], nulls_last=True, maintain_order=True)
    .select(["order_id", "customer", "amount"])
)

df is a LazyFrame, and df.collect() reads it. The steps come in the order you applied them:

In datuiIn the script
The fileThe reader from the table below, with the options datui used (delimiter, header, comment lines, skipped lines and rows, null values). Then the column names datui trimmed, and the text columns it read as numbers or dates. A directory or bucket prefix becomes a glob
Query.filter, .group_by().agg() ordered by the keys, .select, .unique
SQL.sql(..., table_name="df")
A find kept with Ctrl+G.filter on each column as text, pl.any_horizontal across them
Pivot, Melt.group_by().agg() then .pivot(); .unpivot()
Drill-down.filter on the grouped rows with eq_missing
Filters, sort, r.filter, .sort(..., nulls_last=True, maintain_order=True), .reverse()
Hidden and moved columns.select([...])

The reader matches the format datui read the data as, including for a file it recognized by its contents rather than its name (a .bin log, a Parquet part file with no extension):

FormatReader
Parquetpl.scan_parquet
CSVpl.scan_csv
TSVpl.scan_csv
PSVpl.scan_csv
JSONpl.read_json
NDJSONpl.scan_ndjson
Arrow IPCpl.scan_ipc
Avropl.read_avro
ORCdf = ...
Excelpl.read_excel
SafeTensorsdf = ...
GGUFdf = ...
NMEAdf = ...
GPXdf = ...
audiodf = ...
MIDIdf = ...
SQLitepl.read_database
VCDdf = ...
FIXdf = ...
SDFdf = ...
NumPypl.from_numpy
ELFdf = ...
ULogdf = ...
DataFlashdf = ...
candumpdf = ...
textpl.LazyFrame
systemd journalpl.scan_ndjson

A reader that is not a scan reads the whole file and ends in .lazy(). So does an Arrow IPC stream, which is read with pl.read_ipc_stream. A SQLite table is read with SELECT * through Python’s sqlite3, including the one table of a database opened without --table. A NumPy array is loaded with np.load (by its name, from an archive), and its columns get the names datui gives them. When datui read the data lazily but the script reads it whole, a comment says so, in the words of the Info panel’s Read: line: # Read: lazy in datui; pl.read_database reads the file whole into memory.

In these cases the script starts with df = ... for you to fill in, and a comment names the file and the table on screen (flight.bin --table GPS):

  • Data piped in on standard input. If you recorded it with --tee FILE, the script reads FILE instead
  • A format with df = ... above, or a read through a format spec
  • A file compressed with bzip2 or xz
  • A CSV read with --header-rows, --skip-initial-space, or a --comment longer than five characters

A step the script cannot repeat, such as a drill-down into a group whose rows are lists, becomes a comment, and the steps after it are commented out.

A file in an object store is read from the same place, with storage_options holding the settings datui used that are not secret:

Storestorage_options
S3The endpoint and region in effect; for s3://<source>@bucket, the named source’s own
AzureThe account an abfss:// URL names
Any, read with no signatureskip_signature

Credentials are never included. Give Polars yours where it looks for them, such as the provider’s environment variables. pl.read_json, pl.read_avro and pl.read_excel cannot read from an object store, so the script says to download the file. A user name and password in a URL, and an HTTP URL’s query string (where a signed URL keeps its signature), are left out, and a comment says so.

Keys

The dialog takes the keys every dialog takes:

KeyAction
↓ ↑ or Tab Shift+TabMove between rows
← →The previous or next scope, column or format; on Header, toggle
SpaceThe next scope or format; on Column, open its picker; on Header, toggle
EnterCopy, from anywhere in the form; in a picker, choose
?Help
EscClose a picker, then the dialog, without copying

In the column picker, typing narrows the list and ↑ ↓ move.

How the copy reaches the clipboard

[clipboard] backend in the configuration chooses the mechanism:

BackendHow
auto (default)native where a display server answers, osc52 elsewhere
nativeThe display server (Wayland, X11, macOS, Windows), with the HTML flavor
osc52An escape sequence the terminal applies to the system clipboard

osc52 works over SSH because no display server is involved: the terminal you are sitting at does the copy. Terminals limit it:

  • tmux needs set-clipboard on to pass the sequence through.
  • Terminals cap the sequence length, so datui refuses a copy larger than osc52_limit (default 100 KiB) rather than send one that arrives cut short. A Table copy is read in batches and stops at the first batch over the cap, so a copy that is too large is refused without reading the whole table. The clipboard keeps what it held. Some terminals disable OSC 52 writes entirely by default.
  • No HTML flavor: the terminal takes plain text only.

On Wayland and X11, a native copy belongs to the datui process. It stays on the clipboard while datui runs, but quitting can drop it unless a clipboard manager keeps a copy.