Skip to content

Instantly share code, notes, and snippets.

@bvjebin
Last active August 31, 2018 12:18
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 bvjebin/c5de057b75a7b665441585e1f2d7a98b to your computer and use it in GitHub Desktop.
Save bvjebin/c5de057b75a7b665441585e1f2d7a98b to your computer and use it in GitHub Desktop.
Export to csv for medium post
def export_to_csv(data, path) do
file_path = path<>"/export.csv"
result = Enum.map(data, fn item ->
"#{item.name}\",#{item.email},\"#{item.image}"
end)
result = ["Name,Email,Image Url" | result]
File.write!(file_path, Enum.join(result, "\r\n"), [:utf8])
file_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment