fat_table 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-with-dbs.yml +2 -2
- data/CHANGELOG.md +88 -76
- data/CHANGELOG.org +8 -0
- data/README.md +117 -117
- data/README.org +24 -24
- data/benchmark/README.org +238 -0
- data/benchmark/column-baseline-10000.jsonl +5 -0
- data/benchmark/column-fast-10000.jsonl +5 -0
- data/benchmark/column.rb +59 -0
- data/benchmark/formatting-baseline-4000.jsonl +3 -0
- data/benchmark/formatting-buffer-4000.jsonl +3 -0
- data/benchmark/insertion-baseline-1000.jsonl +3 -0
- data/benchmark/insertion-direct-1000.jsonl +3 -0
- data/benchmark/insertion.rb +55 -0
- data/benchmark/joins-baseline-200.jsonl +3 -0
- data/benchmark/joins-indexed-200.jsonl +3 -0
- data/benchmark/joins.rb +87 -0
- data/benchmark/sort-baseline-4000.jsonl +3 -0
- data/benchmark/sort-prepared-4000.jsonl +3 -0
- data/benchmark/sort.rb +57 -0
- data/benchmark/transform_and_render.rb +52 -0
- data/lib/fat_table/column.rb +17 -3
- data/lib/fat_table/convert.rb +6 -0
- data/lib/fat_table/formatters/formatter.rb +13 -13
- data/lib/fat_table/table.rb +115 -39
- data/lib/fat_table/version.rb +1 -1
- data/scripts/benchmark-column +17 -0
- data/scripts/benchmark-compare +105 -0
- data/scripts/benchmark-formatting +17 -0
- data/scripts/benchmark-insertion +17 -0
- data/scripts/benchmark-joins +17 -0
- data/scripts/benchmark-sort +17 -0
- metadata +24 -2
data/README.md
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
<!-- Generated by gem_docs -->
|
|
2
2
|
|
|
3
|
-
- [Version](#
|
|
4
|
-
- [Introduction](#
|
|
5
|
-
- [Installation](#
|
|
6
|
-
- [Using in a gem](#
|
|
7
|
-
- [Manually install](#
|
|
8
|
-
- [Require](#
|
|
9
|
-
- [Usage](#
|
|
10
|
-
- [Quick Start](#
|
|
11
|
-
- [A Word About the Examples](#
|
|
12
|
-
- [Anatomy of a Table](#
|
|
13
|
-
- [Columns](#
|
|
14
|
-
- [Type Keywords Arguments](#
|
|
15
|
-
- [Headers](#
|
|
16
|
-
- [Groups](#
|
|
17
|
-
- [Constructing Tables](#
|
|
18
|
-
- [Empty Tables](#
|
|
19
|
-
- [From CSV or Org Mode files or strings](#
|
|
20
|
-
- [From Arrays of Arrays](#
|
|
21
|
-
- [From Arrays of Hashes](#
|
|
22
|
-
- [From SQL queries](#
|
|
23
|
-
- [Marking Groups in Input](#
|
|
24
|
-
- [Accessing Parts of Tables](#
|
|
25
|
-
- [Rows](#
|
|
26
|
-
- [Columns](#
|
|
27
|
-
- [Cells](#
|
|
28
|
-
- [Other table attributes](#
|
|
29
|
-
- [Operations on Tables](#
|
|
30
|
-
- [Example Input Tables](#
|
|
31
|
-
- [Select](#
|
|
32
|
-
- [Where](#
|
|
33
|
-
- [Order\_by](#
|
|
34
|
-
- [Order\_with](#
|
|
35
|
-
- [Group\_by](#
|
|
36
|
-
- [Join](#
|
|
37
|
-
- [Set Operations](#
|
|
38
|
-
- [Uniq (aka Distinct)](#
|
|
39
|
-
- [Remove groups with degroup!](#
|
|
40
|
-
- [Formatting Tables](#
|
|
41
|
-
- [Available Formatter Output Targets](#
|
|
42
|
-
- [Formatting Directives](#
|
|
43
|
-
- [The `format` and `format_for` methods](#
|
|
44
|
-
- [Footers](#
|
|
45
|
-
- [Invoking Formatters](#
|
|
46
|
-
- [Development](#
|
|
47
|
-
- [Contributing](#
|
|
48
|
-
|
|
49
|
-
Version: 1.1.
|
|
3
|
+
- [Version](#org959c5b8)
|
|
4
|
+
- [Introduction](#org74726d9)
|
|
5
|
+
- [Installation](#org41b3c51)
|
|
6
|
+
- [Using in a gem](#org3a9439f)
|
|
7
|
+
- [Manually install](#org51e29f1)
|
|
8
|
+
- [Require](#org192b858)
|
|
9
|
+
- [Usage](#orgf6e5a85)
|
|
10
|
+
- [Quick Start](#orgdc44022)
|
|
11
|
+
- [A Word About the Examples](#org70afa8f)
|
|
12
|
+
- [Anatomy of a Table](#orge71c5d0)
|
|
13
|
+
- [Columns](#org9e8f9e0)
|
|
14
|
+
- [Type Keywords Arguments](#org7f917ea)
|
|
15
|
+
- [Headers](#org58a34fc)
|
|
16
|
+
- [Groups](#orgdc16786)
|
|
17
|
+
- [Constructing Tables](#orgbf71512)
|
|
18
|
+
- [Empty Tables](#orgbe58231)
|
|
19
|
+
- [From CSV or Org Mode files or strings](#org627a8b2)
|
|
20
|
+
- [From Arrays of Arrays](#org581453d)
|
|
21
|
+
- [From Arrays of Hashes](#org5adbf8b)
|
|
22
|
+
- [From SQL queries](#orgd988464)
|
|
23
|
+
- [Marking Groups in Input](#orgbc3ef75)
|
|
24
|
+
- [Accessing Parts of Tables](#org578bf7a)
|
|
25
|
+
- [Rows](#orgfb4084c)
|
|
26
|
+
- [Columns](#org9e5f58e)
|
|
27
|
+
- [Cells](#org6352861)
|
|
28
|
+
- [Other table attributes](#orga1a983d)
|
|
29
|
+
- [Operations on Tables](#org2870907)
|
|
30
|
+
- [Example Input Tables](#org8c3d2ce)
|
|
31
|
+
- [Select](#orgf373710)
|
|
32
|
+
- [Where](#org59a1f87)
|
|
33
|
+
- [Order\_by](#org963c33f)
|
|
34
|
+
- [Order\_with](#org40647ac)
|
|
35
|
+
- [Group\_by](#org8276a31)
|
|
36
|
+
- [Join](#org361eede)
|
|
37
|
+
- [Set Operations](#org4347b30)
|
|
38
|
+
- [Uniq (aka Distinct)](#orgc2c1d26)
|
|
39
|
+
- [Remove groups with degroup!](#org314f063)
|
|
40
|
+
- [Formatting Tables](#org4cc2b29)
|
|
41
|
+
- [Available Formatter Output Targets](#org8505d97)
|
|
42
|
+
- [Formatting Directives](#orgfc1f527)
|
|
43
|
+
- [The `format` and `format_for` methods](#orgc5763eb)
|
|
44
|
+
- [Footers](#orge9bfaaa)
|
|
45
|
+
- [Invoking Formatters](#orgc8c55cd)
|
|
46
|
+
- [Development](#org0dcb0bd)
|
|
47
|
+
- [Contributing](#org9c4baf5)
|
|
48
|
+
|
|
49
|
+
Version: 1.1.1
|
|
50
50
|
|
|
51
51
|
[](
|
|
52
52
|
https://github.com/ddoherty03/fat_table/actions/workflows/ruby-with-dbs.yml
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
<a id="
|
|
56
|
+
<a id="org959c5b8"></a>
|
|
57
57
|
|
|
58
58
|
# Version
|
|
59
59
|
|
|
@@ -62,11 +62,11 @@ https://github.com/ddoherty03/fat_table/actions/workflows/ruby-with-dbs.yml
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
```
|
|
65
|
-
Current version is: 1.1.
|
|
65
|
+
Current version is: 1.1.1
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
<a id="
|
|
69
|
+
<a id="org74726d9"></a>
|
|
70
70
|
|
|
71
71
|
# Introduction
|
|
72
72
|
|
|
@@ -77,12 +77,12 @@ Furthermore, `FatTable` provides methods for formatting tables and producing out
|
|
|
77
77
|
`FatTable` can be used to perform operations on data that are naturally best conceived of as tables, which in my experience is quite often. It can also serve as a foundation for providing reporting functions where flexibility about the output medium can be useful. Finally `FatTable` can be used within Emacs `org-mode` files in code blocks targeting the Ruby language. Org mode tables are presented to a ruby code block as an array of arrays, so `FatTable` can read them in with its `.from_aoa` constructor. A `FatTable` table output as an array of arrays with its `.to_aoa` output function will be rendered in an org-mode buffer as an org-table, ready for processing by other code blocks.
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
<a id="
|
|
80
|
+
<a id="org41b3c51"></a>
|
|
81
81
|
|
|
82
82
|
# Installation
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
<a id="
|
|
85
|
+
<a id="org3a9439f"></a>
|
|
86
86
|
|
|
87
87
|
## Using in a gem
|
|
88
88
|
|
|
@@ -113,7 +113,7 @@ $ bundle
|
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
<a id="
|
|
116
|
+
<a id="org51e29f1"></a>
|
|
117
117
|
|
|
118
118
|
## Manually install
|
|
119
119
|
|
|
@@ -124,7 +124,7 @@ $ gem install fat_table
|
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
<a id="
|
|
127
|
+
<a id="org192b858"></a>
|
|
128
128
|
|
|
129
129
|
## Require
|
|
130
130
|
|
|
@@ -135,12 +135,12 @@ require 'fat_table'
|
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
<a id="
|
|
138
|
+
<a id="orgf6e5a85"></a>
|
|
139
139
|
|
|
140
140
|
# Usage
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
<a id="
|
|
143
|
+
<a id="orgdc44022"></a>
|
|
144
144
|
|
|
145
145
|
## Quick Start
|
|
146
146
|
|
|
@@ -281,7 +281,7 @@ magick quick.png -resize 600x800 quick_small.png
|
|
|
281
281
|

|
|
282
282
|
|
|
283
283
|
|
|
284
|
-
<a id="
|
|
284
|
+
<a id="org70afa8f"></a>
|
|
285
285
|
|
|
286
286
|
## A Word About the Examples
|
|
287
287
|
|
|
@@ -344,12 +344,12 @@ locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ lib str version
|
|
|
344
344
|
If you use `puts table.to_term`, you can see the effect of the color formatting directives.
|
|
345
345
|
|
|
346
346
|
|
|
347
|
-
<a id="
|
|
347
|
+
<a id="orge71c5d0"></a>
|
|
348
348
|
|
|
349
349
|
## Anatomy of a Table
|
|
350
350
|
|
|
351
351
|
|
|
352
|
-
<a id="
|
|
352
|
+
<a id="org9e8f9e0"></a>
|
|
353
353
|
|
|
354
354
|
### Columns
|
|
355
355
|
|
|
@@ -364,7 +364,7 @@ If you use `puts table.to_term`, you can see the effect of the color formatting
|
|
|
364
364
|
By default, when a `Table` is constructed from an external source, all `Columns` start out having a type of `NilClass`, that is, their type is as yet undetermined. When a string or object is added to a `Column` and it can be converted into one of the permissible types, it fixes the type of the column, and all further items added to the `Column` must either be `nil` (indicating no value) or be capable of being coerced to the column's type. Otherwise, `FatTable` raises an `IncompatibleTypeError` exception.
|
|
365
365
|
|
|
366
366
|
|
|
367
|
-
<a id="
|
|
367
|
+
<a id="org7f917ea"></a>
|
|
368
368
|
|
|
369
369
|
### Type Keywords Arguments
|
|
370
370
|
|
|
@@ -393,7 +393,7 @@ Items of input must be either one of the permissible ruby objects or strings. If
|
|
|
393
393
|
- **NilClass:** Until the input contains a non-blank string that can be parsed as one of the other types, it has this type, meaning that the type is still open. A column comprised completely of blank strings or `nils` will retain the `NilClass` type.
|
|
394
394
|
|
|
395
395
|
|
|
396
|
-
<a id="
|
|
396
|
+
<a id="org58a34fc"></a>
|
|
397
397
|
|
|
398
398
|
### Headers
|
|
399
399
|
|
|
@@ -411,19 +411,19 @@ If no sensible headers can be discerned from the input, headers of the form `:co
|
|
|
411
411
|
You should avoid the use of the column names `:omni` and `:sort_key` because they have special meanings in the `select` and `order_with` commands, respectively.
|
|
412
412
|
|
|
413
413
|
|
|
414
|
-
<a id="
|
|
414
|
+
<a id="orgdc16786"></a>
|
|
415
415
|
|
|
416
416
|
### Groups
|
|
417
417
|
|
|
418
418
|
The rows of a `FatTable` table can be divided into groups, either from markers in the input or as a result of certain operations. There is only one level of grouping, so `FatTable` has no concept of sub-groups. Groups can be shown on output with rules or "hlines" that underline the last row in each group, and you can decorate the output with group footers that summarize the rows in each group.
|
|
419
419
|
|
|
420
420
|
|
|
421
|
-
<a id="
|
|
421
|
+
<a id="orgbf71512"></a>
|
|
422
422
|
|
|
423
423
|
## Constructing Tables
|
|
424
424
|
|
|
425
425
|
|
|
426
|
-
<a id="
|
|
426
|
+
<a id="orgbe58231"></a>
|
|
427
427
|
|
|
428
428
|
### Empty Tables
|
|
429
429
|
|
|
@@ -557,7 +557,7 @@ The rows of a `FatTable` table can be divided into groups, either from markers i
|
|
|
557
557
|
```
|
|
558
558
|
|
|
559
559
|
|
|
560
|
-
<a id="
|
|
560
|
+
<a id="org627a8b2"></a>
|
|
561
561
|
|
|
562
562
|
### From CSV or Org Mode files or strings
|
|
563
563
|
|
|
@@ -614,7 +614,7 @@ tab4 = FatTable.from_org_string(org_body)
|
|
|
614
614
|
```
|
|
615
615
|
|
|
616
616
|
|
|
617
|
-
<a id="
|
|
617
|
+
<a id="org581453d"></a>
|
|
618
618
|
|
|
619
619
|
### From Arrays of Arrays
|
|
620
620
|
|
|
@@ -715,7 +715,7 @@ tab4 = FatTable.from_org_string(org_body)
|
|
|
715
715
|
4. `FatTable` passes back to org-mode an array of arrays using the `.to_aoa` method. In an `org-mode` buffer, these are rendered as tables. We'll often apply `.to_aoa` at the end of example blocks in this `README` to render the results as a table inside this file. As we'll see below, `.to_aoa` can also take a block to which formatting and footer directives can be attached.
|
|
716
716
|
|
|
717
717
|
|
|
718
|
-
<a id="
|
|
718
|
+
<a id="org5adbf8b"></a>
|
|
719
719
|
|
|
720
720
|
### From Arrays of Hashes
|
|
721
721
|
|
|
@@ -752,7 +752,7 @@ tab = FatTable.from_aoh(aoh).to_aoa
|
|
|
752
752
|
| T002 | 2016-11-01 | P | 7.7500 | 200 |
|
|
753
753
|
| T003 | 2016-11-01 | P | 7.5000 | 800 |
|
|
754
754
|
| T004 | 2016-11-01 | S | 7.5500 | 6811 |
|
|
755
|
-
| T005 | 2026-11-
|
|
755
|
+
| T005 | 2026-11-27 | S | 7.5000 | 4000 |
|
|
756
756
|
| T006 | 2016-11-01 | S | 7.6000 | 1000 |
|
|
757
757
|
| T007 | 2016-11-01 | S | 7.6500 | 200 |
|
|
758
758
|
| T008 | 2016-11-01 | P | 7.6500 | 2771 |
|
|
@@ -769,7 +769,7 @@ tab = FatTable.from_aoh(aoh).to_aoa
|
|
|
769
769
|
Notice, again, that the values can either be ruby objects, such as `Date.today`, or strings that can be parsed into one of the permissible column types.
|
|
770
770
|
|
|
771
771
|
|
|
772
|
-
<a id="
|
|
772
|
+
<a id="orgd988464"></a>
|
|
773
773
|
|
|
774
774
|
### From SQL queries
|
|
775
775
|
|
|
@@ -835,7 +835,7 @@ Consult `Sequel's` documentation for details on its connection methods. <http://
|
|
|
835
835
|
The `.connect` function need only be called once, and the database handle it creates will be used for all subsequent `.from_sql` calls until `.connect` is called again.
|
|
836
836
|
|
|
837
837
|
|
|
838
|
-
<a id="
|
|
838
|
+
<a id="orgbc3ef75"></a>
|
|
839
839
|
|
|
840
840
|
### Marking Groups in Input
|
|
841
841
|
|
|
@@ -845,7 +845,7 @@ The `.connect` function need only be called once, and the database handle it cre
|
|
|
845
845
|
|
|
846
846
|
2. When Reading in Tables
|
|
847
847
|
|
|
848
|
-
`FatTable` tables has a concept of "groups" of rows that play a role in many of the methods for operating on them as explained [below](#
|
|
848
|
+
`FatTable` tables has a concept of "groups" of rows that play a role in many of the methods for operating on them as explained [below](#orgdc16786).
|
|
849
849
|
|
|
850
850
|
The `.from_aoa` and `.from_aoh` functions take an optional keyword parameter `hlines:` that, if set to `true`, causes them to mark group boundaries in the table wherever a row Array (for `.from_aoa`) or Hash (for `.from_aoh`) is followed by a `nil`. Each boundary means that the rows above it and after the header or prior group boundary all belong to a group. By default `hlines` is false for both functions so neither expects hlines in its input.
|
|
851
851
|
|
|
@@ -854,12 +854,12 @@ The `.connect` function need only be called once, and the database handle it cre
|
|
|
854
854
|
In org mode table text passed to `.from_org_file` and `.from_org_string`, you *must* mark the header row by following it with an hrule and you *may* mark group boundaries with an hrule. In org mode tables, hlines are table rows beginning with something like `|---`. The `.from_org_...` functions always recognizes hlines in the input, so it takes no `hlines:` keyword parameter.
|
|
855
855
|
|
|
856
856
|
|
|
857
|
-
<a id="
|
|
857
|
+
<a id="org578bf7a"></a>
|
|
858
858
|
|
|
859
859
|
## Accessing Parts of Tables
|
|
860
860
|
|
|
861
861
|
|
|
862
|
-
<a id="
|
|
862
|
+
<a id="orgfb4084c"></a>
|
|
863
863
|
|
|
864
864
|
### Rows
|
|
865
865
|
|
|
@@ -868,14 +868,14 @@ A `FatTable` table is an Enumerable, yielding each row of the table as a Hash ke
|
|
|
868
868
|
You can also use indexing to access a row of the table by number. Using an integer index returns a Hash of the given row. Thus, `tab[20]` returns the 21st data row of the table, while `tab[0]` returns the first row and tab[-1] returns the last row.
|
|
869
869
|
|
|
870
870
|
|
|
871
|
-
<a id="
|
|
871
|
+
<a id="org9e5f58e"></a>
|
|
872
872
|
|
|
873
873
|
### Columns
|
|
874
874
|
|
|
875
875
|
If the index provided to `[]` is a string or a symbol, it returns an Array of the items of the column with that header. Thus, `tab[:ref]` returns an Array of all the items of the table's `:ref` column.
|
|
876
876
|
|
|
877
877
|
|
|
878
|
-
<a id="
|
|
878
|
+
<a id="org6352861"></a>
|
|
879
879
|
|
|
880
880
|
### Cells
|
|
881
881
|
|
|
@@ -889,7 +889,7 @@ tab[:date][13] # => The Date in the 14th row; indexes can be in either order.
|
|
|
889
889
|
```
|
|
890
890
|
|
|
891
891
|
|
|
892
|
-
<a id="
|
|
892
|
+
<a id="orga1a983d"></a>
|
|
893
893
|
|
|
894
894
|
### Other table attributes
|
|
895
895
|
|
|
@@ -926,13 +926,13 @@ Column :shares says its type is 'Numeric' and that is a BigDecimal
|
|
|
926
926
|
```
|
|
927
927
|
|
|
928
928
|
|
|
929
|
-
<a id="
|
|
929
|
+
<a id="org2870907"></a>
|
|
930
930
|
|
|
931
931
|
## Operations on Tables
|
|
932
932
|
|
|
933
933
|
Once you have one or more tables, you will likely want to perform operations on them. The operations provided by `FatTable` are the subject of this section. Before getting into the operations, though, there are a couple of issues that cut across all or many of the operations.
|
|
934
934
|
|
|
935
|
-
First, tables are by-and-large immutable objects: each operation creates a new table without affecting the input tables. The only exceptions are the `degroup!` operation, which mutates the receiver table by removing its group boundaries, and `force_string!` (explained above at [Forcing String Type](#
|
|
935
|
+
First, tables are by-and-large immutable objects: each operation creates a new table without affecting the input tables. The only exceptions are the `degroup!` operation, which mutates the receiver table by removing its group boundaries, and `force_string!` (explained above at [Forcing String Type](#orga76d487)), which forces columns to have the String type despite what the automatic typing rules determine.
|
|
936
936
|
|
|
937
937
|
Second, because each operation returns a `FatTable::Table` object, the operations are chainable.
|
|
938
938
|
|
|
@@ -941,7 +941,7 @@ Third, `FatTable::Table` objects can have "groups" of rows within the table. The
|
|
|
941
941
|
Finally, the operations are, for the most part, patterned on SQL table operations, but when expressions play a role, you write them using ruby syntax rather than SQL.
|
|
942
942
|
|
|
943
943
|
|
|
944
|
-
<a id="
|
|
944
|
+
<a id="org8c3d2ce"></a>
|
|
945
945
|
|
|
946
946
|
### Example Input Tables
|
|
947
947
|
|
|
@@ -1064,7 +1064,7 @@ tab2.to_aoa
|
|
|
1064
1064
|
```
|
|
1065
1065
|
|
|
1066
1066
|
|
|
1067
|
-
<a id="
|
|
1067
|
+
<a id="orgf373710"></a>
|
|
1068
1068
|
|
|
1069
1069
|
### Select
|
|
1070
1070
|
|
|
@@ -1297,28 +1297,28 @@ With the `select` method, you can select columns to appear in the output table,
|
|
|
1297
1297
|
```
|
|
1298
1298
|
| Ref | Traded On | Price | Shares | Cost | Today |
|
|
1299
1299
|
|------+------------+--------+--------+--------+------------|
|
|
1300
|
-
| T001 | 2016-11-01 | 7.7000 | 100 | 3.1416 | 2026-11-
|
|
1301
|
-
| T002 | 2016-11-01 | 7.7500 | 200 | 3.1416 | 2026-11-
|
|
1302
|
-
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-
|
|
1303
|
-
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-
|
|
1300
|
+
| T001 | 2016-11-01 | 7.7000 | 100 | 3.1416 | 2026-11-27 |
|
|
1301
|
+
| T002 | 2016-11-01 | 7.7500 | 200 | 3.1416 | 2026-11-27 |
|
|
1302
|
+
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-27 |
|
|
1303
|
+
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-27 |
|
|
1304
1304
|
|------+------------+--------+--------+--------+------------|
|
|
1305
|
-
| T004 | 2016-11-01 | 7.5500 | 6811 | 3.1416 | 2026-11-
|
|
1306
|
-
| T005 | 2016-11-01 | 7.5000 | 4000 | 3.1416 | 2026-11-
|
|
1307
|
-
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-
|
|
1308
|
-
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-
|
|
1309
|
-
| T007 | 2016-11-01 | 7.6500 | 200 | 3.1416 | 2026-11-
|
|
1310
|
-
| T008 | 2016-11-01 | 7.6500 | 2771 | 3.1416 | 2026-11-
|
|
1311
|
-
| T009 | 2016-11-01 | 7.6000 | 9550 | 3.1416 | 2026-11-
|
|
1305
|
+
| T004 | 2016-11-01 | 7.5500 | 6811 | 3.1416 | 2026-11-27 |
|
|
1306
|
+
| T005 | 2016-11-01 | 7.5000 | 4000 | 3.1416 | 2026-11-27 |
|
|
1307
|
+
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-27 |
|
|
1308
|
+
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-27 |
|
|
1309
|
+
| T007 | 2016-11-01 | 7.6500 | 200 | 3.1416 | 2026-11-27 |
|
|
1310
|
+
| T008 | 2016-11-01 | 7.6500 | 2771 | 3.1416 | 2026-11-27 |
|
|
1311
|
+
| T009 | 2016-11-01 | 7.6000 | 9550 | 3.1416 | 2026-11-27 |
|
|
1312
1312
|
|------+------------+--------+--------+--------+------------|
|
|
1313
|
-
| T010 | 2016-11-01 | 7.5500 | 3175 | 3.1416 | 2026-11-
|
|
1314
|
-
| T011 | 2016-11-02 | 7.4250 | 100 | 3.1416 | 2026-11-
|
|
1315
|
-
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-
|
|
1316
|
-
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-
|
|
1317
|
-
| T013 | 2016-11-02 | 7.3500 | 53100 | 3.1416 | 2026-11-
|
|
1313
|
+
| T010 | 2016-11-01 | 7.5500 | 3175 | 3.1416 | 2026-11-27 |
|
|
1314
|
+
| T011 | 2016-11-02 | 7.4250 | 100 | 3.1416 | 2026-11-27 |
|
|
1315
|
+
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-27 |
|
|
1316
|
+
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-27 |
|
|
1317
|
+
| T013 | 2016-11-02 | 7.3500 | 53100 | 3.1416 | 2026-11-27 |
|
|
1318
1318
|
|------+------------+--------+--------+--------+------------|
|
|
1319
|
-
| T014 | 2016-11-02 | 7.4500 | 5847 | 3.1416 | 2026-11-
|
|
1320
|
-
| T015 | 2016-11-02 | 7.7500 | 500 | 3.1416 | 2026-11-
|
|
1321
|
-
| T016 | 2016-11-02 | 8.2500 | 100 | 3.1416 | 2026-11-
|
|
1319
|
+
| T014 | 2016-11-02 | 7.4500 | 5847 | 3.1416 | 2026-11-27 |
|
|
1320
|
+
| T015 | 2016-11-02 | 7.7500 | 500 | 3.1416 | 2026-11-27 |
|
|
1321
|
+
| T016 | 2016-11-02 | 8.2500 | 100 | 3.1416 | 2026-11-27 |
|
|
1322
1322
|
```
|
|
1323
1323
|
|
|
1324
1324
|
5. Custom Instance Variables and Hooks
|
|
@@ -1375,7 +1375,7 @@ With the `select` method, you can select columns to appear in the output table,
|
|
|
1375
1375
|
As the example illustrates, `.select` transmits any group boundaries in its input table to the result table.
|
|
1376
1376
|
|
|
1377
1377
|
|
|
1378
|
-
<a id="
|
|
1378
|
+
<a id="org59a1f87"></a>
|
|
1379
1379
|
|
|
1380
1380
|
### Where
|
|
1381
1381
|
|
|
@@ -1402,7 +1402,7 @@ tab1.where('@row.even? && (g10 || qp10)').to_term
|
|
|
1402
1402
|
```
|
|
1403
1403
|
|
|
1404
1404
|
|
|
1405
|
-
<a id="
|
|
1405
|
+
<a id="org963c33f"></a>
|
|
1406
1406
|
|
|
1407
1407
|
### Order\_by
|
|
1408
1408
|
|
|
@@ -1445,7 +1445,7 @@ The interesting thing about `order_by` is that, while it ignores groups in its i
|
|
|
1445
1445
|
Sorting with `order_by` is stable: keys that are equal maintain the order they had in the unsorted table.
|
|
1446
1446
|
|
|
1447
1447
|
|
|
1448
|
-
<a id="
|
|
1448
|
+
<a id="org40647ac"></a>
|
|
1449
1449
|
|
|
1450
1450
|
### Order\_with
|
|
1451
1451
|
|
|
@@ -1495,7 +1495,7 @@ tab1.order_with('price * shares').to_aoa
|
|
|
1495
1495
|
```
|
|
1496
1496
|
|
|
1497
1497
|
|
|
1498
|
-
<a id="
|
|
1498
|
+
<a id="org8276a31"></a>
|
|
1499
1499
|
|
|
1500
1500
|
### Group\_by
|
|
1501
1501
|
|
|
@@ -1543,7 +1543,7 @@ Here is a list of all the aggregate methods available. If the description restri
|
|
|
1543
1543
|
Perhaps surprisingly, the `group_by` method ignores any groups in its input and results in no group boundaries in the output since each group formed by the implicit `order_by` on the grouping columns is collapsed into a single row.
|
|
1544
1544
|
|
|
1545
1545
|
|
|
1546
|
-
<a id="
|
|
1546
|
+
<a id="org361eede"></a>
|
|
1547
1547
|
|
|
1548
1548
|
### Join
|
|
1549
1549
|
|
|
@@ -1768,7 +1768,7 @@ Perhaps surprisingly, the `group_by` method ignores any groups in its input and
|
|
|
1768
1768
|
```
|
|
1769
1769
|
|
|
1770
1770
|
|
|
1771
|
-
<a id="
|
|
1771
|
+
<a id="org4347b30"></a>
|
|
1772
1772
|
|
|
1773
1773
|
### Set Operations
|
|
1774
1774
|
|
|
@@ -2053,7 +2053,7 @@ tab2.to_aoa
|
|
|
2053
2053
|
```
|
|
2054
2054
|
|
|
2055
2055
|
|
|
2056
|
-
<a id="
|
|
2056
|
+
<a id="orgc2c1d26"></a>
|
|
2057
2057
|
|
|
2058
2058
|
### Uniq (aka Distinct)
|
|
2059
2059
|
|
|
@@ -2085,7 +2085,7 @@ tab1.uniq.to_aoa
|
|
|
2085
2085
|
```
|
|
2086
2086
|
|
|
2087
2087
|
|
|
2088
|
-
<a id="
|
|
2088
|
+
<a id="org314f063"></a>
|
|
2089
2089
|
|
|
2090
2090
|
### Remove groups with degroup!
|
|
2091
2091
|
|
|
@@ -2120,7 +2120,7 @@ tab1.degroup!.to_aoa
|
|
|
2120
2120
|
```
|
|
2121
2121
|
|
|
2122
2122
|
|
|
2123
|
-
<a id="
|
|
2123
|
+
<a id="org4cc2b29"></a>
|
|
2124
2124
|
|
|
2125
2125
|
## Formatting Tables
|
|
2126
2126
|
|
|
@@ -2131,7 +2131,7 @@ In addition, you can add any number of footers to a table, which appear at the e
|
|
|
2131
2131
|
If the target output medium does not support a formatting directive or the directive does not make sense, it is simply ignored. For example, you can output an `org-mode` table as a String, and since `org-mode` does not support colors, any color directives are ignored. Some of the output targets are not strings, but ruby data structures, and for them, things such as alignment are irrelevant.
|
|
2132
2132
|
|
|
2133
2133
|
|
|
2134
|
-
<a id="
|
|
2134
|
+
<a id="org8505d97"></a>
|
|
2135
2135
|
|
|
2136
2136
|
### Available Formatter Output Targets
|
|
2137
2137
|
|
|
@@ -2266,7 +2266,7 @@ If the target output medium does not support a formatting directive or the direc
|
|
|
2266
2266
|
```
|
|
2267
2267
|
|
|
2268
2268
|
|
|
2269
|
-
<a id="
|
|
2269
|
+
<a id="orgfc1f527"></a>
|
|
2270
2270
|
|
|
2271
2271
|
### Formatting Directives
|
|
2272
2272
|
|
|
@@ -2333,7 +2333,7 @@ Here is a list of all the formatting directives that apply to each cell type:
|
|
|
2333
2333
|
For example, you might want to use `n[-]Cc[purple]` to make =nil=s visible as a centered purple hyphen.
|
|
2334
2334
|
|
|
2335
2335
|
|
|
2336
|
-
<a id="
|
|
2336
|
+
<a id="orgc5763eb"></a>
|
|
2337
2337
|
|
|
2338
2338
|
### The `format` and `format_for` methods
|
|
2339
2339
|
|
|
@@ -2432,7 +2432,7 @@ All the other cells in the table, namely the cells in the `:join_date` column, h
|
|
|
2432
2432
|
The `string: 'R'` directive causes all the cells to be right-aligned except `:id` which specifies centering for the `:id` column only. The `n[N/A]` directive for specifies how nil are displayed in the numeric column, `:salary`, but not for other nils, such as in the last row of the `:join_date` column.
|
|
2433
2433
|
|
|
2434
2434
|
|
|
2435
|
-
<a id="
|
|
2435
|
+
<a id="orge9bfaaa"></a>
|
|
2436
2436
|
|
|
2437
2437
|
### Footers
|
|
2438
2438
|
|
|
@@ -2638,7 +2638,7 @@ All the other cells in the table, namely the cells in the `:join_date` column, h
|
|
|
2638
2638
|
+-------------+-------+-----+------------+--------+-------------+
|
|
2639
2639
|
| Average | | 31 | | 31,429 | 29-DEC-2005 |
|
|
2640
2640
|
+-------------+-------+-----+------------+--------+-------------+
|
|
2641
|
-
| Report Date | | 8 | | |
|
|
2641
|
+
| Report Date | | 8 | | | 27-NOV-2026 |
|
|
2642
2642
|
+=============+=======+=====+============+========+=============+
|
|
2643
2643
|
```
|
|
2644
2644
|
|
|
@@ -2668,7 +2668,7 @@ All the other cells in the table, namely the cells in the `:join_date` column, h
|
|
|
2668
2668
|
+----------------+-------+-----+------------+--------+-------------+
|
|
2669
2669
|
| Average | | 31 | | 31,429 | 29-DEC-2005 |
|
|
2670
2670
|
+----------------+-------+-----+------------+--------+-------------+
|
|
2671
|
-
| Lottery Winner | | 8 | | |
|
|
2671
|
+
| Lottery Winner | | 8 | | | 3 |
|
|
2672
2672
|
+================+=======+=====+============+========+=============+
|
|
2673
2673
|
```
|
|
2674
2674
|
|
|
@@ -2752,7 +2752,7 @@ All the other cells in the table, namely the cells in the `:join_date` column, h
|
|
|
2752
2752
|
```
|
|
2753
2753
|
|
|
2754
2754
|
|
|
2755
|
-
<a id="
|
|
2755
|
+
<a id="orgc8c55cd"></a>
|
|
2756
2756
|
|
|
2757
2757
|
### Invoking Formatters
|
|
2758
2758
|
|
|
@@ -2888,7 +2888,7 @@ As the examples show, one way to invoke the formatting methods is simply to call
|
|
|
2888
2888
|
```
|
|
2889
2889
|
|
|
2890
2890
|
|
|
2891
|
-
<a id="
|
|
2891
|
+
<a id="org0dcb0bd"></a>
|
|
2892
2892
|
|
|
2893
2893
|
# Development
|
|
2894
2894
|
|
|
@@ -2897,7 +2897,7 @@ After checking out the repo, run \`bin/setup\` to install dependencies. Then, ru
|
|
|
2897
2897
|
To install this gem onto your local machine, run \`bundle exec rake install\`.
|
|
2898
2898
|
|
|
2899
2899
|
|
|
2900
|
-
<a id="
|
|
2900
|
+
<a id="org9c4baf5"></a>
|
|
2901
2901
|
|
|
2902
2902
|
# Contributing
|
|
2903
2903
|
|
data/README.org
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#+PROPERTY: header-args:bash :exports code :eval no
|
|
12
12
|
|
|
13
13
|
# gem_docs:version begin
|
|
14
|
-
Version: 1.1.
|
|
14
|
+
Version: 1.1.1
|
|
15
15
|
# gem_docs:version end
|
|
16
16
|
|
|
17
17
|
|
|
@@ -29,7 +29,7 @@ https://github.com/ddoherty03/fat_table/actions/workflows/ruby-with-dbs.yml
|
|
|
29
29
|
|
|
30
30
|
#+RESULTS:
|
|
31
31
|
#+begin_example
|
|
32
|
-
Current version is: 1.1.
|
|
32
|
+
Current version is: 1.1.1
|
|
33
33
|
#+end_example
|
|
34
34
|
|
|
35
35
|
* Introduction
|
|
@@ -923,7 +923,7 @@ tab = FatTable.from_aoh(aoh).to_aoa
|
|
|
923
923
|
| T002 | 2016-11-01 | P | 7.7500 | 200 |
|
|
924
924
|
| T003 | 2016-11-01 | P | 7.5000 | 800 |
|
|
925
925
|
| T004 | 2016-11-01 | S | 7.5500 | 6811 |
|
|
926
|
-
| T005 | 2026-11-
|
|
926
|
+
| T005 | 2026-11-27 | S | 7.5000 | 4000 |
|
|
927
927
|
| T006 | 2016-11-01 | S | 7.6000 | 1000 |
|
|
928
928
|
| T007 | 2016-11-01 | S | 7.6500 | 200 |
|
|
929
929
|
| T008 | 2016-11-01 | P | 7.6500 | 2771 |
|
|
@@ -1537,28 +1537,28 @@ You can set a column to a constant of any of the acceptable types, ~Numeric~,
|
|
|
1537
1537
|
#+begin_example
|
|
1538
1538
|
| Ref | Traded On | Price | Shares | Cost | Today |
|
|
1539
1539
|
|------+------------+--------+--------+--------+------------|
|
|
1540
|
-
| T001 | 2016-11-01 | 7.7000 | 100 | 3.1416 | 2026-11-
|
|
1541
|
-
| T002 | 2016-11-01 | 7.7500 | 200 | 3.1416 | 2026-11-
|
|
1542
|
-
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-
|
|
1543
|
-
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-
|
|
1540
|
+
| T001 | 2016-11-01 | 7.7000 | 100 | 3.1416 | 2026-11-27 |
|
|
1541
|
+
| T002 | 2016-11-01 | 7.7500 | 200 | 3.1416 | 2026-11-27 |
|
|
1542
|
+
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-27 |
|
|
1543
|
+
| T003 | 2016-11-01 | 7.5000 | 800 | 3.1416 | 2026-11-27 |
|
|
1544
1544
|
|------+------------+--------+--------+--------+------------|
|
|
1545
|
-
| T004 | 2016-11-01 | 7.5500 | 6811 | 3.1416 | 2026-11-
|
|
1546
|
-
| T005 | 2016-11-01 | 7.5000 | 4000 | 3.1416 | 2026-11-
|
|
1547
|
-
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-
|
|
1548
|
-
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-
|
|
1549
|
-
| T007 | 2016-11-01 | 7.6500 | 200 | 3.1416 | 2026-11-
|
|
1550
|
-
| T008 | 2016-11-01 | 7.6500 | 2771 | 3.1416 | 2026-11-
|
|
1551
|
-
| T009 | 2016-11-01 | 7.6000 | 9550 | 3.1416 | 2026-11-
|
|
1545
|
+
| T004 | 2016-11-01 | 7.5500 | 6811 | 3.1416 | 2026-11-27 |
|
|
1546
|
+
| T005 | 2016-11-01 | 7.5000 | 4000 | 3.1416 | 2026-11-27 |
|
|
1547
|
+
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-27 |
|
|
1548
|
+
| T006 | 2016-11-01 | 7.6000 | 1000 | 3.1416 | 2026-11-27 |
|
|
1549
|
+
| T007 | 2016-11-01 | 7.6500 | 200 | 3.1416 | 2026-11-27 |
|
|
1550
|
+
| T008 | 2016-11-01 | 7.6500 | 2771 | 3.1416 | 2026-11-27 |
|
|
1551
|
+
| T009 | 2016-11-01 | 7.6000 | 9550 | 3.1416 | 2026-11-27 |
|
|
1552
1552
|
|------+------------+--------+--------+--------+------------|
|
|
1553
|
-
| T010 | 2016-11-01 | 7.5500 | 3175 | 3.1416 | 2026-11-
|
|
1554
|
-
| T011 | 2016-11-02 | 7.4250 | 100 | 3.1416 | 2026-11-
|
|
1555
|
-
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-
|
|
1556
|
-
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-
|
|
1557
|
-
| T013 | 2016-11-02 | 7.3500 | 53100 | 3.1416 | 2026-11-
|
|
1553
|
+
| T010 | 2016-11-01 | 7.5500 | 3175 | 3.1416 | 2026-11-27 |
|
|
1554
|
+
| T011 | 2016-11-02 | 7.4250 | 100 | 3.1416 | 2026-11-27 |
|
|
1555
|
+
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-27 |
|
|
1556
|
+
| T012 | 2016-11-02 | 7.5500 | 4700 | 3.1416 | 2026-11-27 |
|
|
1557
|
+
| T013 | 2016-11-02 | 7.3500 | 53100 | 3.1416 | 2026-11-27 |
|
|
1558
1558
|
|------+------------+--------+--------+--------+------------|
|
|
1559
|
-
| T014 | 2016-11-02 | 7.4500 | 5847 | 3.1416 | 2026-11-
|
|
1560
|
-
| T015 | 2016-11-02 | 7.7500 | 500 | 3.1416 | 2026-11-
|
|
1561
|
-
| T016 | 2016-11-02 | 8.2500 | 100 | 3.1416 | 2026-11-
|
|
1559
|
+
| T014 | 2016-11-02 | 7.4500 | 5847 | 3.1416 | 2026-11-27 |
|
|
1560
|
+
| T015 | 2016-11-02 | 7.7500 | 500 | 3.1416 | 2026-11-27 |
|
|
1561
|
+
| T016 | 2016-11-02 | 8.2500 | 100 | 3.1416 | 2026-11-27 |
|
|
1562
1562
|
#+end_example
|
|
1563
1563
|
|
|
1564
1564
|
**** Custom Instance Variables and Hooks
|
|
@@ -3214,7 +3214,7 @@ column.
|
|
|
3214
3214
|
+-------------+-------+-----+------------+--------+-------------+
|
|
3215
3215
|
| Average | | 31 | | 31,429 | 29-DEC-2005 |
|
|
3216
3216
|
+-------------+-------+-----+------------+--------+-------------+
|
|
3217
|
-
| Report Date | | 8 | | |
|
|
3217
|
+
| Report Date | | 8 | | | 27-NOV-2026 |
|
|
3218
3218
|
+=============+=======+=====+============+========+=============+
|
|
3219
3219
|
#+end_example
|
|
3220
3220
|
|
|
@@ -3244,7 +3244,7 @@ But it can be any type. Here we pick a lottery winner from the employee ids.
|
|
|
3244
3244
|
+----------------+-------+-----+------------+--------+-------------+
|
|
3245
3245
|
| Average | | 31 | | 31,429 | 29-DEC-2005 |
|
|
3246
3246
|
+----------------+-------+-----+------------+--------+-------------+
|
|
3247
|
-
| Lottery Winner | | 8 | | |
|
|
3247
|
+
| Lottery Winner | | 8 | | | 3 |
|
|
3248
3248
|
+================+=======+=====+============+========+=============+
|
|
3249
3249
|
#+end_example
|
|
3250
3250
|
|