PHP code example of fiedsch / quancept-log-parser

1. Go to this page and download the library: Download fiedsch/quancept-log-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fiedsch / quancept-log-parser example snippets




use Fiedsch\Data\File\FixedWidthReader;
use Fiedsch\Data\File\Helper;
use Fiedsch\Quancept\Logs\Accounts;

$input = "/path/to/your/accounts.sms";

// the columns to be read from $input into our data array

$columns = [
    'interviewer' => ['from' => Accounts::INTERVIEWER_FROM, 'to' => Accounts::INTERVIEWER_TO],
    'kex'         => ['from' => Accounts::RECORD_KEY_FROM,  'to' => Accounts::RECORD_KEY_TO],
    'timestried'  => ['from' => Accounts::TIMESTRIED_FROM,  'to' => Accounts::TIMESTRIED_TO],
    'start_day'   => ['from' => Accounts::START_DATE_FROM,  'to' => Accounts::START_DATE_TO],
    'start_time'  => ['from' => Accounts::START_TIME_FROM,  'to' => Accounts::START_TIME_TO],
    'duration'    => ['from' => Accounts::DURATION_FROM,    'to' => Accounts::DURATION_TO],
    'tipcode'     => ['from' => Accounts::TIPCODE_FROM,     'to' => Accounts::TIPCODE_TO],
    'exitcode'    => ['from' => Accounts::EXITCODE_FROM,    'to' => Accounts::EXITCODE_TO],
    'queuename'   => ['from' => Accounts::QUEUENAME_FROM,   'to' => Accounts::QUEUENAME_TO],
];

// read file line by line

$reader = new FixedWidthReader($input, $columns);

$aggregated = [];

while (($line = $reader->getLine(FixedWidthReader::SKIP_EMPTY_LINES)) !== null) {
    // trim all data as they might contain surrounding spaces
    $data = array_map(function($el) { return trim($el); }, $line);
    // ignore lines generated by the QTS dialer with no interviewer interaction
    if ($data[0] === Accounts::AGENT_QTS) { continue; }
    // reorganize our data array such that the array keys are the names in $columns
    $data = Helper::setArrayKeys($data, array_keys($columns));
    // change numeric value to label
    if (isset(Accounts::EXITCODES[$data['exitcode']])) {
        $data['exitcode'] = Accounts::EXITCODES[$data['exitcode']];
    }
    // do something with $data here (e.g. aggregate values in $aggregated) 
    // Fit to your needs!
}

$results = new QcaResults();
// read lines of the `*.qca` file into $data
// for every line do:
    $results->addInterviewerRecord($data[Qca::USERNAME], $data);
    $results->addDayRecord(date("ymd", $data[Qca::INTERVIEWSTARTTIMESTAMP]), $data);

$results = new AccountsResults();
// read lines of the `accounts.sms` file into $data
// for every line do:
    $results->addInterviewerRecord($data[AccountsResults::INTERVIEWER], $data);
    $results->addDayRecord($data[AccountsResults::START_DAY], $data);