Double quotes on numbers
ch33foong opened this issue · 2 comments
ch33foong commented
Hi,
how can I force number field to be double quoted?
Does the library support this?
Thanks.
beatrichartz commented
Sure, when encoding you can define the way the data gets encoded:
defimpl CSV.Encode, for: MyData do
def encode(%MyData{has: fun}, env \\ []) do
"so much #{fun}" |> CSV.Encode.encode(env)
end
end
So you should also be able to do:
defimpl CSV.Encode, for: Integer do
def encode(integer, env \\ []) do
"#{integer}" |> CSV.Encode.encode(env)
end
end
sebastialonso commented
Is this kind of protocol available for Decoding also?