Last active
August 31, 2018 12:18
-
-
Save bvjebin/c5de057b75a7b665441585e1f2d7a98b to your computer and use it in GitHub Desktop.
Export to csv for medium post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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