2017 © Pedro Peláez
 

library quancept-log-parser

a library with helpers for managing quancept cati log files

image

fiedsch/quancept-log-parser

a library with helpers for managing quancept cati log files

  • Thursday, July 12, 2018
  • by fiedsch
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Parse Quancept CATI log files

Quancept generates log files. Among these are accounts.sms and <projectname>.qca., (*1)

This library provides classes that help to make parsing these files easier., (*2)

This is Work in Progress. If you find something missing or wrong, please consider opening an issue or even better make a pull request., (*3)

Usage

Installation

composer require "fiedsch/quancept-log-parser <version>"

where <version> is a versionstring like 0.2.0., (*4)

Example one parse accounts.sms

require __DIR__ . "/vendor/autoload.php";

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!
}

Helpers

QcaResults

$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);

AccountsResults

$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);

Aggregation of QcaResults and AccountsResults

  • TODO

The Versions

12/07 2018

dev-master

9999999-dev

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati

17/02 2018

0.4.1

0.4.1.0

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati

15/02 2018

0.3.0

0.3.0.0

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati

14/02 2018

0.2.0

0.2.0.0

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati

14/02 2018

0.1.1

0.1.1.0

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati

13/02 2018

0.1.0

0.1.0.0

a library with helpers for managing quancept cati log files

  Sources   Download

MIT

The Requires

 

csv data fixed width log files quancept cati