IEX for Rapid Text Processing

Yesterday I found myself having to modify several thousand lines of a CSV that was somehow exported poorly. As I started to think about this, I realized that the REPL of IEX and pattern matching would make this a piece of cake.

What I ended up doing looked like this:

> s ='source.csv') |>\1)
> File.write 'out.csv', s

What I liked about this is that I was able to write mutate_line\1 inline as an anonymous function and I could immediately, safely see the results. Elixir statelessness meant that the call to\2 was returning a fresh Enum and that I didn't even have to think to know that my source data was safe. This let me iterate over development of the mutate_line\1 function while abstracting away all unnecessary details.

The point of this is that I've been thoroughly bought-in to the advantages of stateless functional programming for application safety, correctness, and development speed for some time. But it's nice to know that my favorite language is also convenient for garbage throwaway processing.

William ByattComment