Parsing file into nested dictionary

Viewed 134

I have a config file that I would like to read with the following format

[key_1]
inner_key_1 inner_entry_1
inner_key_2 inner_entry_2
inner_key_3 inner_entry_3
inner_key_4 inner_entry_4
[key_2]
inner_key_5 inner_entry_5
inner_key_6 inner_entry_6
inner_key_7 inner_entry_7
inner_key_8 inner_entry_8

Which would then be mapped into a nested Elixir dictionary like such.

%{key_1 => %{inner_key_1 => inner_entry_1, ... }, key_2 => %{inner_key_5 => inner_entry_5,...}}

I am having trouble conceptualizing how to do this with Elixir and functional programming. I have tried using the Stream library in order to achieve this but have had no luck.

1 Answers
Related