Open deni-zen opened 8 years ago
It might be useful to provide something like:
$reader = new CSVelte\Reader($fn, $flvr);
$reader->copy(new Flavor(array('delimiter' => "\t")));
Also, for the filter functionality I think I might prefer a syntax more like this:
<?php
$reader = CSVelte::reader('./files/data.csv', $flavor);
$reader->addFilter(function($row) {
return (!empty($row['email']));
})->addFilter(function($row) {
if ($row->doesSomeShit()) {
return (count($row) == get_some_value($row));
}
});
foreach ($reader as $line_no => $row) {
// now only filtered rows will be iterated...
}
There are definitely methods I want to implement from Underscore but they'll have to wait for a later version. Pushing this to v0.2.
Pushing to v0.3
Check out all these functions that can be applied to arrays using the underscore library:
http://brianhaveri.github.io/Underscore.php/
Take a look and see if you think it would be useful to implement any of those methods in the Reader class. I already included filter() in the documentation so add that at the very least. See the docs for how it's supposed to work.
This guy has some good ideas too...
http://csv.thephpleague.com/reading/