joegreen88 / smrtr-datagrid Goto Github PK
View Code? Open in Web Editor NEWA 2D array wrapper with methods for operating on, importing & exporting tabular data
A 2D array wrapper with methods for operating on, importing & exporting tabular data
Suggest a new class, Smrtr\DataGridFormula
. Let objects of this type be assigned to cells as values. Formula objects have a method evaluate
which is triggerred by the DataGrid when getting values including that cell, and passes in the X and Y position of the cell being evaluated as well as a reference to the grid for looking up other cell values. The Formula looks up the values, evaluates the result, and passes the result back as the return value. The DataGrid then replaces the formula object with the value in the returned data, without removing the formula from $grid->data.
Some helper methods on the Grid object would be useful too:
flatten()
which evaluates all formulas and replaces the formulas with the calculated values.info('formulas')
which gets a count of formulas on the grid (this info can be cached on the instance)there is more that can be done, this is just the groundwork.
It will be useful to have methods on hand which delete empty rows/columns to clean up the grid.
Smrtr_DataGrid => \Smrtr\DataGrid
namespace Smrtr;
$grid = new DataGrid;
// filter out empty rows
$grid = $grid->filterRows(function($key, $label, $row) {
return array_reduce($row, function(&$keep, $value){
$keep = '' === (string) $value ? $keep : true;
return $keep;
}, false);
});
$grid->searchRows('slug=joe + name=joe') will not return any results when it should.
Currently if I want to use the searchRows() method on a grid with no column labels then i am in a bit of a bind.
Suggest using some notation to access keys just like we access labels. One such mapping could be /n
where n
is the key we want to search on.
Example:
$grid->searchRows('/0*=a + /2<50');
i.e. find rows where the first column contains a value containing the 'a' character and the third column contains a value less than 50.
The unit tests should be able to run independently of Zend Framework, to integrate with 3rd party testing services. Some refactoring is required to make this possible.
Implement Serializable on the DataGrid.
Implement two functions, queryRows()
and queryColumns()
, which search the DataGrid for rows and columns respectively which match the provided key(s).
e.g. $Grid->queryRows(array('first_name'=>'Joseph'))
Need to explore this idea in alot more detail and prototype some ideas at home.
$value
)$value
, $rowOrColumn
, $keyOrLabel
)$value
, $rowKeyOrLabel
)$value
, $columnKeyOrLabel
)Method called save which saves the grid to a file. Writes a serialized instance by default and can also proxy to saveCsv and saveJson via a parameter.
Yaml parsing and writing
$grid->eachRow(function($key, $row){ $row['slug'] = trim($row['slug'],'/'); },true);
$grid3 = $grid->filterRows(function($key, $label, $row){ // keep top level pages return !stristr($row[0],'/'); });
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.