https://github.com/xepozz/clk-parser
Parses *.clk buffers and presents table name, columns and values as separated entities.
https://github.com/xepozz/clk-parser
clickhouse clk kittenhouse parser php
Last synced: about 1 month ago
JSON representation
Parses *.clk buffers and presents table name, columns and values as separated entities.
- Host: GitHub
- URL: https://github.com/xepozz/clk-parser
- Owner: xepozz
- Created: 2024-04-21T18:13:53.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-21T18:26:38.000Z (about 2 years ago)
- Last Synced: 2025-07-28T10:11:09.525Z (11 months ago)
- Topics: clickhouse, clk, kittenhouse, parser, php
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KittenHouse *.clk files Parser
[](https://packagist.org/packages/xepozz/clk-parser)
[](https://packagist.org/packages/xepozz/clk-parser)
[](https://github.com/xepozz/clk-parser/actions)
[](https://codecov.io/gh/xepozz/clk-parser)
[](https://shepherd.dev/github/xepozz/clk-parser)
Parses `*.clk` buffers and presents table name, columns and values as separated entities.
## Installation
```shell
composer req xepozz/clk-parser
```
## Usage
```php
$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
```php
$parser = new \Xepozz\ClkParser\Parser();
$result = $parser->parseContent(<<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,'']"
}
}
*/
```