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

Save and apply views

A view saves the active sample, query, filters, sort, column layout, frozen columns, reshape and chart, and applies them to the next file of the same shape. v opens the views list.

Save and reuse a query

Central Park’s daily highs, in NOAA’s public weather data, for 2024 and then 2023:

  1. Open s3://noaa-ghcn-pds/parquet/by_year/YEAR=2024/ELEMENT=TMAX/, as the datui argument or from the home screen: Enter on NOAA daily weather (GHCN-D), → on by_year and on YEAR=2024, then Enter on ELEMENT=TMAX. Typing narrows each list.
  2. Run the station query: 366 rows.
  3. Press v, then s. The name starts as the directory’s, ELEMENT=TMAX: type Central Park highs over it and press Enter to save.
  4. Open YEAR=2023/ELEMENT=TMAX/ the same way. Press v: the view is listed with Match same columns. Press Enter.

The view runs the query on 2023: 365 rows, 2023-01-01 to 2023-12-31.

The Views list over NOAA’s YEAR=2023/ELEMENT=TMAX: Central Park highs, matched by same columns

Does a view saved on 2024 fit 2023? v on YEAR=2023/ELEMENT=TMAX: Central Park highs, matched by same columns.

The view applied to 2023: day and high_c, 365 rows from 2023-01-01

Enter applies it: 365 daily highs of 2023, 12.8 °C on New Year’s Day.

A view stores transformations, not a copy of the data. The next file produces its own results.

A view withWhen applied
A sampleDraws it again from its scope, method, size and seed: the same rows, never stored. Its query, filters and sort go on as the rows arrive
A chartLands on the table; c draws the chart, with its options and how it was last exported. The footer offers c

Saving is unavailable until the current table has a change to store. In the description field, Enter inserts a newline; Ctrl+J saves from there, or Tab out and press Enter. The form takes the keys every dialog takes; in the description, ↑ ↓ move between its lines first.

Open the views list

KeyAction
vOpen the views list
VApply the best-matching view without opening the list; when none matches, the list opens instead

When V or automatic application applies a view, the footer names it and says why it matched: View "Central Park highs" applied: same columns.

Or from the command line, with --view: replace <NAME> with the view’s name and <PATH> with what to open, as in datui --view "Central Park highs" s3://noaa-ghcn-pds/parquet/by_year/YEAR=2022/ELEMENT=TMAX/:

datui --view "<NAME>" <PATH>

A view’s pivot and first rows are read in the background, with a spinner in the footer. Esc stops it and keeps the table as it was. A view that fails on the data is not applied, and a dialog says why.

List controls

Views are listed by how well they fit the open file, and a score mark beside each says how well. A check mark marks the one currently applied, and the Match column says why a view fits:

MatchThe view’s rule that fits
same fileExact path or relative path
same columnsSchema
globPath pattern or filename pattern
KeyAction
EnterApply the selected view
sSave the current state as a new view
eEdit the selected view
dDelete it, after confirming: the question starts on No; ← picks Delete, Enter confirms
iShow how the selected view’s score was computed
EscClose

Save a view

The save form starts with the filename as its name, which is required, selected: typing replaces it, and an arrow key keeps it for editing. Add a description if needed, then expand Matching with Space to choose which files should match the view:

MatchFits a file when
Exact pathits absolute path, or its URL for remote data, is the same
Relative pathits path relative to the current directory is the same; local files only
Path patternits path matches a glob
Filename patternits name matches a glob
Schemait has all the view’s columns; extra columns are fine

A view saved on one table of a SQLite database or NumPy archive records the table, shown as Table under Matching. Its path rules then fit only that table: shop.db/orders and shop.db --table orders are the same file, and shop.db/customers is not. Schema matching still carries the view to any table with its columns.

Data piped to standard input and frames passed from Python (datui.view(frame)) have no path, so their views match by schema alone.

Schema matching is enabled by default. It records the columns as loaded, before the query, so a view whose query renames columns still matches the next file. Matching views rank above unrelated ones, and matches combine: a view fitting by relative path and exact schema outranks one fitting by exact path alone. A file whose columns merely include the view’s scores low, below a pattern match. Other match rules, and how often and how recently a view was used, also affect the score. Press i to inspect it. V and automatic application use only views with a matching rule.

Only the active query is saved, in its own mode: SQL, Text or q. Filters, sort, column order and reshape are saved regardless. After a pivot or melt, the view also keeps the query, filters and sort the reshape ran over, and applies them before it. A reshape of a reshape, such as a melt of a pivot, cannot be replayed: the view keeps only the last one.

Editing (e) changes a view’s name, description and matching. Its saved settings — and the columns its schema rule matches on — follow the table only while the view is the one applied, so renaming a view never overwrites what it carries.

Apply on open

views.auto_apply applies the best-matching view when a file opens:

[views]
auto_apply = true

Manage views

Views are JSON files in the views/ directory beside your config file.

CommandDoes
datui views listList the saved views: name, what files they match, when last used
datui views rm <NAME>Remove one
datui views clearRemove them all