diff --git a/lib/instream/decoder/csv.ex b/lib/instream/decoder/csv.ex index 653048c9..35ce4f82 100644 --- a/lib/instream/decoder/csv.ex +++ b/lib/instream/decoder/csv.ex @@ -55,7 +55,7 @@ defmodule Instream.Decoder.CSV do defp parse_datatypes({{field, "boolean"}, _}), do: {field, false} defp parse_datatypes({{field, "double"}, "+Inf"}), do: {field, :infinity} defp parse_datatypes({{field, "double"}, "-Inf"}), do: {field, :neg_infinity} - defp parse_datatypes({{field, "double"}, value}), do: {field, String.to_float(value)} + defp parse_datatypes({{field, "double"}, value}), do: {field, Float.parse(value) |> elem(0)} defp parse_datatypes({{field, "duration"}, value}), do: {field, String.to_integer(value)} defp parse_datatypes({{field, "long"}, value}), do: {field, String.to_integer(value)} defp parse_datatypes({{field, "unsignedLong"}, value}), do: {field, String.to_integer(value)} diff --git a/test/instream/decoder/csv_test.exs b/test/instream/decoder/csv_test.exs index bca82bff..31a713c5 100644 --- a/test/instream/decoder/csv_test.exs +++ b/test/instream/decoder/csv_test.exs @@ -435,6 +435,7 @@ defmodule Instream.Decoder.LineTest do #datatype,string,double\r type,value\r double,10.20\r + double,10\r double,+Inf\r double,-Inf\r double,\r @@ -445,6 +446,10 @@ defmodule Instream.Decoder.LineTest do "type" => "double", "value" => 10.20 }, + %{ + "type" => "double", + "value" => 10.0 + }, %{ "type" => "double", "value" => :infinity