Tokenised Csv Reader that handles some of the strange configurations databases and application use.
- Parses tokens and csv from streams and outputs using a Lazy Iterator
| Csv Feature | Example | Array |
|---|---|---|
| Delimiter | `thing | other` |
| Quote Enclosure | "quote, here",not here | ['quote, here', 'not here'] |
| Escaping | "\"text","new\\nline" | ['"text',"new\\\nline"] |
| Double Quotes | """text","more" | ['"text','more'] |
| Double Quotes and Escaping | """text","\, text" | ['"text',', text'] |
| Null value parsing | "text",\\N,"text" | ['text',null,'text'] |
| Boolean value parsing | "text",false,true | ['text',false,true] |
| Numeric value parsing | "text",1,-2.3,3.1e-24 | ['text',1,-2.3,3.1e-24] |
| Handling of Byte Order Marks | <UTF8BOM>"text","things" | ['text','things'] |
Via Composer
$ composer require graze/csv-token$csvDefinition = newCsvDefinition();
$reader = newReader($csvDefinition, $stream);
$iterator = $reader->read();// $stream = '"some","text",true,false,0,1,2';$csvDefiniton = newCsvDefinition();
$parser = newParser([newBoolValueParser(), newNumberValueParser()]);
$tokeniser = newStreamTokeniser($csvDefinition, $stream);
$iterator = $parser->parser($tokeniser->getTokens());
var_dump(iterator_to_array($iterator));
-> [['some','text',true,false,0,1,2]]Please see CHANGELOG for more information what has changed recently.
$ make testPlease see CONTRIBUTING for details.
If you discover any security related issues, please email security@graze.com instead of using the issue tracker.
- Harry Bragg
- All Contributors
- Original Idea: jfsimon/php-csv
The MIT License (MIT). Please see License File for more information.