Skip to content

Commit

Permalink
Drop leading empty columns from CSV results
Browse files Browse the repository at this point in the history
  • Loading branch information
mneudert committed Apr 3, 2021
1 parent 3435107 commit 22093f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/instream/decoder/csv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ defmodule Instream.Decoder.CSV do
@spec parse(binary) :: [map]
def parse(response) do
case __MODULE__.Parser.parse_string(response, skip_headers: false) do
[["" | _ = headers] | [_ | _] = rows] ->
Enum.map(rows, fn ["" | row] -> headers |> Enum.zip(row) |> Map.new() end)

[[_ | _] = headers | [_ | _] = rows] ->
Enum.map(rows, fn row -> headers |> Enum.zip(row) |> Map.new() end)

Expand Down

0 comments on commit 22093f2

Please sign in to comment.