Skip to content

Instantly share code, notes, and snippets.

@noelworden
Last active December 1, 2020 15:20
Show Gist options
  • Save noelworden/68daa4da50c3d518577ff3a6685515f6 to your computer and use it in GitHub Desktop.
Save noelworden/68daa4da50c3d518577ff3a6685515f6 to your computer and use it in GitHub Desktop.
#blog_snippets
def csv_row_to_table_record(file) do
column_names = get_column_names(file)
file
|> File.stream!()
|> CSV.parse_stream(skip_headers: true)
|> Enum.map(fn row ->
row
|> Enum.with_index()
|> Map.new(fn {val, num} -> {column_names[num], val} end)
|> create_or_skip()
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment