Giter Site home page Giter Site logo

clk-parser's Introduction

KittenHouse *.clk files Parser

Latest Stable Version Total Downloads phpunit codecov type-coverage

Parses *.clk buffers and presents table name, columns and values as separated entities.

Installation

composer req xepozz/clk-parser

Usage

$parser = new \Xepozz\ClkParser\Parser();
$result = $parser->parseContent(file_get_contents('/path/to/file.clk'));

$result->table // access table name
$result->columns // access array of column names
$result->values // access iterable values in a pair of column names: [column => value, ...] 

Example

$parser = new \Xepozz\ClkParser\Parser();

$result = $parser->parseContent(<<<TEXT
# started at 15-Apr-24 08:06:25 # schema.table_name(date,email,event,params)9F9C34E2
(1111,'email','Startup',[1,2,3]),(2222,'email','Click',[])4CDA8189
(-1111,'','Shutdown',[-1,'string',3,''])4CDA8189
TEXT
);

Result is an object of type \Xepozz\ClkParser\Result:

echo $result->table; 
// schema.table_name

var_dump($result->columns); 
/**
array(4) {
  [0]=>
  string(4) "date"
  [1]=>
  string(5) "email"
  [2]=>
  string(5) "event"
  [3]=>
  string(6) "params"
}
*/

var_dump(iterator_to_array($result->values));
/**
array(3) {
  [0]=>
  array(4) {
    ["date"]=>
    string(4) "1111"
    ["email"]=>
    string(7) "'email'"
    ["event"]=>
    string(9) "'Startup'"
    ["params"]=>
    string(7) "[1,2,3]"
  }
  [1]=>
  array(4) {
    ["date"]=>
    string(4) "2222"
    ["email"]=>
    string(7) "'email'"
    ["event"]=>
    string(7) "'Click'"
    ["params"]=>
    string(2) "[]"
  }
  [2]=>
  array(4) {
    ["date"]=>
    string(5) "-1111"
    ["email"]=>
    string(2) "''"
    ["event"]=>
    string(10) "'Shutdown'"
    ["params"]=>
    string(18) "[-1,'string',3,'']"
  }
}
*/

clk-parser's People

Contributors

xepozz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.