nozavroni / csvelte

🕺🏻 CSV and Tabular Data library for PHP
http://phpcsv.com/
Other
6 stars 0 forks source link

Write AppendStream class #132

Open nozavroni opened 7 years ago

nozavroni commented 7 years ago

Write an AppendStream class that allows you to append stream classes together one after another so that once one reached eof(), it begins reading from the next one. It keeps doing this until all of its child streams are exhausted and then eof() returns true. Stream will be readable, but not writable. It will be seekable but only to data that has already been read.

This will allow you do combine multiple CSV files by appending their streams.

$uristream = new Stream('http://www.example.com/data/products.csv', 'rb');
$products = new Stream('./data/products.csv', 'r+b');
$stream = new IteratorStream(new SplFileObject('./data/products2.csv'));
$appStr = new AppendStream($uristream, $products, $stream);