Creating Flows and Reading Files
Reading files from the file system is easy with Elixir, but there are a few things you have to consider when consuming file data and transforming it to common Elixir data structures. In this section, we will introduce Flow by comparing it to the Enum and Stream modules and see how we can reduce system memory usage and increase performance when reading files.
We are going to add a function that returns all airports from the airports.csv file that are currently in operation. To do this, we have to read the file and remove all closed airports from the list of results. We will convert the results to an Elixir Map, keeping only the data attributes that we are interested in.
We will start with the most obvious implementation. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access