Skip to content

Instantly share code, notes, and snippets.

@mattsan
Created April 28, 2019 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsan/5c593288b9f9c126ea41fdd4aae4c101 to your computer and use it in GitHub Desktop.
Save mattsan/5c593288b9f9c126ea41fdd4aae4c101 to your computer and use it in GitHub Desktop.
# sample of CSV package
#
# see https://hex.pm/packages/csv
"a,b\n1,2\n3,4\n"
|> IO.inspect()
|> String.split() # split a string into lines
|> IO.inspect()
|> CSV.decode!(headers: [:a, :b]) # decode with headers
|> Enum.to_list() # realize a list of maps
|> IO.inspect()
|> CSV.encode(headers: true) # encode with headers
|> Enum.to_list() # realise a list of strings
|> IO.inspect()
|> IO.puts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment