Download the PHP package dantleech/data-table without Composer
On this page you can find all versions of the php package dantleech/data-table. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dantleech/data-table
More information about dantleech/data-table
Files in dantleech/data-table
Package data-table
Short Description Represent and analyze tabular data
License MIT
Informations about the package data-table
Cellular
ABANDONED: Use Tabular instead.
The cellular library provides an object oriented way of building, representing and analyzing tabular data.
Features:
- Supports aggregate functions
sum
,avg
,min
,max
andmedian
. - Aggreate functions can applied to
Table
,Row
andColumn
. - Supports cell groups.
- Callbacks can be applied to cells on whole, or selected groups of
Table
,Row
andColumn
instances. - Produce grouped tables with callbacks - analagous to
SELECT bar, SUM(foo) FROM sometable GROUP BY bar
- Fluent table builder
Note that this library is under development.
Creating
Col 1 | Col 2 | Col 3 |
---|---|---|
12 | 14 | 4 |
12 | 14 | 4 |
Would be created as follows:
``
Or without the builder:
``
Retrieving cell values
You can retrieve values from Table
, Row
and Column
instances as follows:
``
Groups
You apply groups to cells:
``
Using the Calculator
The calculator allows you to apply certain calculations to values, Cell
instances or any instance of CellularInterface
:
``
Current functions:
sum
: Return the sum of valuesmin
: Return the minimum valuemax
: Return the maximum valuemean
: Return the mean (average) valuemedian
: Return the median valuedeviation
: Return the deviation as a percentage
Partitioning and Forking
Table
and Row
instances provide the following methods:
partition
: Internally divide the collection of elements according to a given callback.aggregate
: Aggregate the partitions of a table back to a single partition.
This is useful for creating summaries from multiple tables or rows:
For example:
``
The callback is passed each partition in turn alongisde a new instance of the collection class. The callback's responsiblity is to add new rows to the new instance, the primary partition of which will become the new primary partition for the collection upon which the operation is performed.
The result will be anagous to the following SQL: SELECT SUM(number) FROM table GROUP BY class
.
Sorting
Sorting can be achieved as follows:
``
Evaluating values
Values can be evaluated as follows:
``
The callback is passed the element and the previous result. The initial result
is given as the second argument to evaluate
.
Setting Attributes
It is possible to set attributes on Cell
and Cellular
instances. This is
useful when you need to store metadata about the source of the data before it
was transformed into cellular form.
``
Other methods
filter
: Filter the results by a closure. Returns a new instance.clear
: Clear the collection