The code for this tutorial can be found on GitHub.
We open handles to both files, the first in read mode and the second in write mode. One reason for this is that protocols need to handle directory operations, whereas filters only need to handle each chunk of data.
In an asynchronous execution model like with multi-process or multi-threaded PHP applicationsboth CPU and memory usage are important considerations. In traditional PHP architecture, these generally become a problem when either one reaches the limits of the server. We can then pipe this compressed data into another file.
We could want to read and process data all at the same time, outputting the processed data or performing other actions based on what we read.
The CSV File In this tutorial, we will work initially with a very basic comma separated values file, but also later in the article, we can start to swap the delimiter with other special characters like semi-colons etc. If we need to work on the data, generators are probably the best way.