Having FatTable infer column types from the content of a table is nice, but as I learned from the need to have force_string!, sometimes we want to restrict the type of the column and throw an error if the content does not conform. So, perhaps when the table columns are specified, we can allow them to be terminated with a “sigil” that restricts its type:
- @
- at Date or DateTime column,
- #
- a Numeric column
- ?
- a Boolean column
- ~
- a String Column,
- *
- a tolerant Column, i.e., it infers the type from the content, but allows strings to be added as items in an otherwise typed column but treat them a nil for calculation purposes.
- @*, #*, ?*
- a Date, Numeric, or Boolean column that is also tolerant. `~*` could be treated the same as `~`.
Allow a formatter to specify column widths. This could be a number of characters, which would be interpreted as a number of “ems” for LaTeX. Cell content larger than the width would be truncated. Any column without a width specified would be set at the width of the longest value in that cell, after initial formatting.
tab.to_text do |f|
f.widths(a: 13, b: 30)
end
Possible enhancements:
- specify an overall width and column widths as decimal or fractions, so that a column’s width would be that fraction of the overall width.
- specify a Range for a width, so that the column would at least min and at most max, otherwise the width of its largest cell.
- State “TODO” from [2017-04-21 Fri 10:36]
This is a gem that I can include into the Table model to convert a table into a spread-sheet, or even a sheet in a multi-sheet spreadsheet file.
Perhaps an obvious formatter would be HTML tables, but CSS controls the styling, so have to think on that one.
These would need no color formatting and might prove useful.
Possible replacements for YQL.
- State “TODO” from [2017-04-21 Fri 10:35]
Cancelled because Yahoo shut down the YQL api service.
Add a constructor to allow fetching stock data from yql. Perhaps grab all available fields, then allow a select of those of interest.
Either by a single string argument as the sole argument to order_by, or use another method, such a order_with. Note that this can be done now by creating a new column having the sort expression with select and then just order_by that column. Perhaps that is an easy way to implement it.- State “WAIT” from “TODO” [2017-12-29 Fri 05:34]
- State “TODO” from [2017-11-27 Mon 04:46]
After applying avg, does the column have the proper Numeric or Date, or DateTime type. How about Boolean aggregates?
- State “WAIT” from “TODO” [2017-04-21 Fri 10:36]
- State “TODO” from [2017-04-21 Fri 10:35]
Need to think about ways to define formatters for Table for different output types, including tty, color-tty, latex, csv, spreadsheet?
- State “WAIT” from “TODO” [2017-04-21 Fri 10:36]
- State “TODO” from [2017-04-21 Fri 10:35]
If I want a table to perform sub-totals at various break points, need to have a way for a table to record its grouping boundaries. Maybe an array of row numbers? Automatically injected by the group-by method?
- State “WAIT” from “TODO” [2017-03-02 Thu 15:54]
- State “TODO” from [2017-03-02 Thu 15:54]
For tables, add a method that eliminates any duplicate rows. Perhaps just apply Array#uniq to the columns?