KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to select from CSV Datastore #703

Open Eugene opened this topic on on Feb 23, 2019 - 1 comments

Eugene commented on Feb 23, 2019

The previous topic became too long for a wiki article... so this is the short version

  • to add names to CSV columns you do
->pipe(new ColumnRename(array(
                    "Column 0" => "your_name_for_column_0",
                    "Column 1" => "your_name_for_column_1",
                    "Column 2" => "your_name_for_column_2",
                    ...
                )))

see ColumnRename process in the documentation

  • to have separate access to date and time if you have mixed datetime column you do
->pipe(new CopyColumn(array(
                "date"=>"datetime",
                "time"=>"datetime",
            )))
->pipe(new DateTimeFormat(array(
                "date" => "Y-m-d",
                "time" => "H:i:s"
            )))

see CopyColumn process and DateTimeFormat processin the documentation

  • to select data with AND conditions you do
->pipe(new Filter(array(
    array("code","=",1000),
    array("date",">=","2019-02-01"),
    array("date","<=","2019-02-28"),
    array("flag","=",0)
)))

(using >= and <= for the date works like BETWEEN) see Filter process in the documentation

  • to select data with OR conditions you do
->pipe(new Filter(array(
    array("value","<",10),
 'or',
    array("value",">",30),
)))

After the operator or, all the condition below will use or, if you want and again, you need to use 'and'

  • for more complicated conditions like (a AND b) OR (c AND d) you do
->pipe(new Custom(function($row){
    if( (($row["a"] && $row["b"]) || ($row["c"] && $row["d"]) )
    {
        return $row;
    }
}))

see Custom process in the documentation

  • to group data you do
->pipe(new Group(array(
    "by"=>"date",
    "max"=>"datetime"
)))

"max" - is an example only see Group process in the documentation

  • to join CSV with another data source you do

 $join = new Join($first_source, $second_source, 
                   array("matching column1" => "matching column2"));

see Join process in the documentation

KoolReport commented on Feb 24, 2019

Thank you very much! Very appreciate your summarization!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
wiki

None