Skip to content

1.3.0

Latest

Choose a tag to compare

@github-actions github-actions released this 19 Oct 11:29

This is the first release since 2021. It rebuilds the plugin on current versions of csv-parse and filtrex, which brings working date handling and a few things that were quietly wrong in 1.2 (maxRows, failed filters), and it requires Obsidian 1.13.1 or newer. Existing csvtable blocks were checked expression by expression against 1.2's behaviour, so the differences you can see are the ones listed under Breaking changes at the end.

At a glance

Features

  • Dates — cast_date never reached the parser, so dates were always text and couldn't be compared as dates
  • Current csv-parse options — the Readme linked csv-parse's current docs, but the plugin ran a 2021 version that ignored newer option names
  • Numeric and date column names — a header like 2020 or 2021-01-01 couldn't be shown, filtered or sorted
  • Errors that name the option — a malformed block said "Could not parse CSV table spec" and nothing else

Bug fixes

  • maxRows counted the wrong rows — it limited rows read, not rows shown, and sorting ran on that prefix
  • A failed filter showed every row — an unknown function or a typo let the whole file through
  • Smaller fixes — byte order marks, empty files, short first rows, the stylesheet's width rule, the error box

Features

Dates: cast_date never reached the parser, so dates were always text

The problem: The Readme said cells were cast "to an integer, boolean, or date object". Numbers were; dates were not. The plugin dropped the cast_date option before calling csv-parse, so csvOptions: {cast_date: true} did nothing, every date cell stayed text, and a filter like start >= "2021-10-28" only worked when the file happened to write its dates year-first (#4). csv-parse's own date casting, had it been reachable, reads a bare date as UTC midnight and a date with a time in local time, so start == "2021-10-28" would have failed west of UTC.

What's new: cast_date: true works. With it on, every cell JavaScript can read as a date becomes one, read in your local time zone whether or not it carries a time, so both sides of start >= "2021-10-28" mean the same instant. A date cell displays as 2021-01-11, or 2021-01-11 08:00 when it has a time, instead of a quoted ISO timestamp, and ~= matches against that same text. The header line is never cast. It stays off by default, as it effectively always was.

source: meetings.csv
csvOptions:
  cast_date: true
filter: start >= "2021-10-28"
sortBy: start

Without it, dates written year-first still filter and sort correctly as text, which is what 1.2 did.

Current csv-parse options: the Readme linked docs for a parser the plugin didn't run

The problem: The csvOptions section pointed at csv-parse's current documentation, but the plugin bundled csv-parse 4 from 2021. Options added or renamed since — relax_quotes, skip_records_with_error, group_columns_by_name — were silently ignored, and the camelCase spellings csv-parse accepts (castDate, skipEmptyLines) bypassed the plugin's own defaults.

What's new: The plugin runs csv-parse 7, so the options on csv.js.org work as written. The names csv-parse 4 used (relax, skip_lines_with_empty_values, skip_lines_with_error, columns_duplicates_to_array) still work too, and camelCase spellings are treated the same as snake_case ones. When a block gives both an old and a new name, the new one wins.

Numeric and date column names: a header like 2020 broke the table

The problem: csv-parse 4 refused a header cell it had cast to a number, so a CSV with a 2020 column didn't render at all. A header like 2021-01-01 rendered, but couldn't be named in columns, sortBy or columnVariables: YAML reads the unquoted form as a date, and the plugin threw on it.

What's new: Numeric headers render. In the block, a number or an unquoted date is read back as the column's name wherever a name goes (columns, columnVariables, and {name: …}), and where an expression goes (sortBy, expression: …) it is turned into filtrex's quoted-symbol form, '2020', so it reads the column rather than the constant. Any column whose name isn't a valid identifier — spaces, accents — can be written that way directly, 'Localité' == "Paris", which filtrex has always allowed and the Readme now says so (#7). A date with a time has to be quoted, since YAML can't hand it back as written.

Errors that name the option: a malformed block said only "Could not parse CSV table spec"

The problem: The block's YAML was used as-is. csvOptions written as a list rather than a mapping (#29), a filter given as a mapping, or maxRows: ten produced either a generic parse error or a table that silently ignored the option.

What's new: Each option is checked, and a wrong shape is reported by name: Parameter 'csvOptions' must be a mapping of csv-parse option names to values. A key left blank is treated as not given, as before. source also accepts a leading / or ./ and backslashes.

Bug fixes

maxRows limited the rows read, not the rows shown

The problem: maxRows cut the file off before filtering: the filter ran over the first N rows and the table showed however many of those passed. sortBy then sorted only that prefix. A block asking for the five most populous countries with sortBy: {expression: population, reversed: true} and maxRows: 5 got the first five rows of the file, in population order.

What's new: Rows are filtered, then sorted, then cut to maxRows, as the Readme always described. A block that combined maxRows with filter or sortBy will show different rows after upgrading; one that used maxRows alone is unaffected.

A failed filter expression showed every row

The problem: filtrex 2 reported a runtime error — an unknown function, a misspelled one — by returning the error object instead of throwing, and an error object is truthy. A filter like contains(name, "a") therefore matched every row, and a column expression that failed showed {} in every cell, with nothing to say anything had gone wrong.

What's new: A filter, column or sort expression that fails at runtime shows its error in place of the table, as a syntax error already did. Sort errors are reported as sort errors rather than being blamed on the filter.

Also fixed

  • A byte order mark at the start of a UTF-8 CSV (Excel writes one) became part of the first column's name, so that column couldn't be referenced. It's skipped by default; bom: false in csvOptions restores the old behaviour.
  • An empty CSV, or one with only a header line, threw "Cannot convert undefined or null to object" instead of rendering an empty table. Column names now come from the header line, so under relax_column_count a short first row no longer drops columns from the whole table.
  • styles.css has always set .csv-table { width: 100% }, but only the error block carried that class; tables are now rendered with it and fill the note's width.
  • The error block had ten lines of padding on every side of a one-line message. It has one.

Breaking changes and migration

What changed: The plugin requires Obsidian 1.13.1 or newer, and filtrex 3 replaces filtrex 2 for expressions. Its comparison and arithmetic operators have been made to behave as they did (text and numbers coerce as in JavaScript; a blank cell is zero in arithmetic; population == "50340000" still matches a numeric cell), but two differences could not be undone.

You are affected if you...

  • run Obsidian older than 1.13.1 — you'll stay on 1.2.0.
  • apply and, or or not to a column that isn't true or false: not retired on a text column, or name and population > 5. filtrex 3 requires boolean operands and won't let that be overridden, so the block now shows an error. Compare instead: not (population > 100000000), retired == false.
  • use a comparison as a column (columns: [population > 1000000]) — it displays true/false rather than 1/0. Arithmetic on it is unchanged.
  • combine maxRows with filter or sortBy — see the fix above; the rows shown change.
  • rely on tables not filling the note's width.

Not affected: blocks that use source, columns, columnVariables, filter and sortBy with plain comparisons — every example in the Readme — render as before.

No escape hatch for the operator change, and the previous version of the plugin is still installable from its release if you need to wait. The Readme's "Upgrading from 1.2" section has the full list.