Skip to content

Instantly share code, notes, and snippets.

@mhanberg
Created September 14, 2022 00:14
Show Gist options
  • Save mhanberg/2c300fd6297c9b2e6c363d1c37820a56 to your computer and use it in GitHub Desktop.
Save mhanberg/2c300fd6297c9b2e6c363d1c37820a56 to your computer and use it in GitHub Desktop.
"some.CSV" |> File.read!() |> NimbleCSV.RFC4180.parse_string() |> Enum.group_by(fn t -> if(Enum.at(t, 2) =~ "Amazon", do: "Amazon" , else: Enum.at(t, 2)) end) |> Enum.map(fn {category, ts} -> {category, Enum.map(ts, &String.to_float(Enum.at(&1, 5)) |> abs()) |> Enum.sum} end) |> Enum.sort_by(fn {k, v} -> v end, :desc) |> inspect(pretty: true, limit: :infinity) |> IO.puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment