In case anyone is interested, I have figured out how to create, modify and display virtual tables in Coda. These virtual tables can be useful for certain stastical and noncyclical-graph data analysis.
Virtual Tables
Sometimes it is useful to represent a table as a matrix; M, aka, list-of-lists.
Formulas can address arbitrary values using
M.nth(I).nth(J)
which facilitates rapid matrix operations used in maths, stats, AI, and graph-theory.
I use use the Apache Parquet format for virtual tables. Where the first column is the row-identifier and the last column is a list of the column names. This is used in ābig dataā applications to load large SQL tables into memory for faster processing. This format preserves the data labels as well as the values.
I have done this in Coda as follows;
Create a virtual table V from a coda table P which has columns Product, Size, Quantity, Priceā¦
Which produces a list-of-lists like thisā¦
We GET the cell for row & col as follows (where row=id of the row, col=name of the column) as follows;
- first it finds the index of the column using find(col) on the list of column names
- then it finds the index of the row using find(row) on the column-list
- finally it uses the nth() formulas to return the cell value
We can MODIFY a cell for row & col using the splice() formula as follows
The result is a new virtual table with the single cell at row & col changed to value
Note that this is NOT an action formula. So it does not need to be in a BUTTON or AUTOMATION.
We can manipulate virtual tables inside ordinary column formulas (or canvas formulas).
The resulting virtual table is updated immidiately without the need to click a button.
We can display the virtual table using this codeā¦
Which looks like this;
![image](https://us1.discourse-cdn.com/flex016/uploads/coda1/original/3X/9/0/90808d270cf7eb4f6088e4803b21357d3449281c.png)
I have made a pack for all this (and many more operations) for my clients.
If anyone is interested, I can get permission to publish it to the gallery.
Max