A Labeled Tab-separated Values parser implementation in Elixir
Add :ltsv
library to your project's dependencies in mix.exs
:
defp deps do
[
{:ltsv, "~> 0.1"}
]
end
And fetch:
$ mix deps.get
iex> LTSV.parse("name:taka\taddress:Seattle\\nname:neko\taddress:near") |> Enum.map(&Dict.to_list/1)
[[{"name", "taka"}, {"address", "Seattle"}], [{"name", "neko"}, {"address", "near"}]]
iex> LTSV.dump [%{"address" => "Seattle", "name" => "taka"}, %{"address" => "Chicago", "name" => "tetsuo"}]
"address:Seattle\tname:taka\naddress:Chicago\tname:tetsuo"
iex> LTSV.dump [%{name: "taka"}]
"name:taka"
Copyright © 2014 Takayuki Matsubara, released under the MIT license.