script
Nested list value inside map csv export
The code is working fine it takes list of maps convert them into csv and export the value. This is the code
def to_csv(map, path) do
file = File.open!(path, [:write, :utf8])
map
|> IO.inspect()
|> CSV.encode(headers: true)
|> Enum.each(&IO.write(file, &1))
end
This is the list of maps
%{
name: "Kelsie",
date_of_birth: ~D[1944-06-02],
end_date: ~D[2017-10-30],
category_id: [14, 9, 19, 14],
room_name: "Filomena",
id: 11,
},
%{
name: "Karson",
date_of_birth: ~D[1944-06-02],
end_date: ~D[2017-11-04],
category_id: [15, 19, 7, 14, 9],
room_name: "Bert",
id: 12,
}
]
File is exporting successfully but the list of category ids not inserting . I just got \t\n in the place of category id.
Any suggestions?
If its possible?
Thanks
First Post!
NobbZ
Last Post!
script
Thanks for your answer. I just went with using map instead of list for category_id and encode it with poison. It seems to work
0
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
I would like to know what is the best IDE for elixir development?
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









