defmodule CSV do @moduledoc """ Helper to interact with CSV """ def parse(path) do content = File.read!(path) [_ | parts] = String.replace(content, "\r", "") |> String.split("\n") |> Enum.filter(fn v -> v != "" end) names = Enum.map(parts, fn v -> [name | _ ] = String.split(v, ";") String.trim(name, "\"") end) students = Enum.map(names, fn v -> IO.inspect(v) [_, lastname, firstname] = Regex.run(~r/(^[A-Z -]{2,}) (.+)/, v) {lastname, firstname} end) {:ok, students} end end