Big CSV

The report shows how to build report from a big CSV file

MonthAmount
May, 2005 $4,824
June, 2005 $9,632
July, 2005 $28,374
August, 2005 $24,072
February, 2006 $514

In many case, data is stored in big CSV or spreadsheet files. The BigSpreadsheetDataSource in Excel package will help us to read data from those file and pipe their data into our processing chain.

    public function settings()
    {
        return array(
            "dataSources"=>array(
                "big_csv"=>array(
                    "class"=>'\koolreport\excel\BigSpreadsheetDataSource',
                    "filePath"=>"/var/storage/big_sales.csv",
                    "fieldSeparator"=>"\t",
                )
            )
        );
    }
<?php
require_once "SakilaRental.php";

$report = new SakilaRental;
$report->run()->render();
<?php

require_once "../../../load.koolreport.php";

use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;

class SakilaRental extends KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sakila_rental"=>array(
                    'class' => '\koolreport\excel\BigSpreadsheetDataSource',      
                    'filePath'=>dirname(__FILE__)."/sakila_rental.csv"
                )
            )
        );
    }   
    protected function setup()
    {
        $this->src('sakila_rental')
        ->pipe(new TimeBucket(array(
            "payment_date"=>"month"
        )))
        ->pipe(new Group(array(
            "by"=>"payment_date",
            "sum"=>"amount"
        )))
        ->pipe($this->dataStore('sale_by_month'));
    } 
}
<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\ColumnChart;
?>

<div class="report-content">

    <div class="text-center">
        <h1>Big CSV</h1>
        <p class="lead">The report shows how to build report from a big CSV file</p>
    </div>

    <?php
    ColumnChart::create(array(
        "dataStore"=>$this->dataStore('sale_by_month'),  
        "columns"=>array(
            "payment_date"=>array(
                "label"=>"Month",
                "type"=>"datetime",
                "format"=>"Y-n",
                "displayFormat"=>"F, Y",
            ),
            "amount"=>array(
                "label"=>"Amount",
                "type"=>"number",
                "prefix"=>"$",
            )
        ),
        "width"=>"100%",
    ));
    ?>

    <?php
    Table::create(array(
        "dataStore"=>$this->dataStore('sale_by_month'),
        "columns"=>array(
            "payment_date"=>array(
                "label"=>"Month",
                "type"=>"datetime",
                "format"=>"Y-n",
                "displayFormat"=>"F, Y",
            ),
            "amount"=>array(
                "label"=>"Amount",
                "type"=>"number",
                "prefix"=>"$",
                        )
        ),
        "cssClass"=>array(
            "table"=>"table table-hover table-bordered"
        )
    ));
    ?>

</div>
payment_dateamount
2005-05-25 11:30:37 2.99
2005-05-28 10:35:23 0.99
2005-06-15 00:54:12 5.99
2005-06-15 18:02:53 0.99
2005-06-15 21:08:46 9.99
2005-06-16 15:18:57 4.99
2005-06-18 08:41:48 4.99
2005-06-18 13:33:59 0.99
2005-06-21 06:24:45 3.99
2005-07-08 03:17:05 5.99

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro