-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Description
I'm noticing some weird stuff happening with the decoder when I call it multiple times in an IEx session.
Given a file my_file.csv with ~200 lines, doing
File.stream!("my_file.csv") |> CSV.Decoder.decode(num_pipes: 1) |> Enum.take(2)yields the first 2 lines of the file the first time I run it, but subsequent invocations yield seemingly random / out-of-order lines.
I also get strange behavior when working with a simple stream (although I'm not able to reproduce the ordering issue):
iex(1)> stream = ~w(1,2,3,4 5,6,7,8 9,10,11,12 13,14,15,16) |> Stream.map(&(&1))
#Stream<[enum: ["1,2,3,4", "5,6,7,8"],
funs: [#Function<45.113986093/1 in Stream.map/2>]]>
iex(2)> stream |> Enum.take(2)
["1,2,3,4", "5,6,7,8"]
iex(3)> stream |> Enum.take(2)
["1,2,3,4", "5,6,7,8"]
iex(4)> CSV.Decoder.decode(stream, num_pipes: 1) |> Enum.take(2)
#Function<25.113986093/2 in Stream.resource/3>
iex(5)> CSV.Decoder.decode(stream, num_pipes: 1) |> Enum.take(2)
[["1", "2", "3", "4"], ["5", "6", "7", "8"]]
iex(6)> CSV.Decoder.decode(stream, num_pipes: 1) |> Enum.take(2)
[]
iex(7)> CSV.Decoder.decode(stream, num_pipes: 1) |> Enum.take(2)
[["1", "2", "3", "4"], ["5", "6", "7", "8"]]
iex(8)> CSV.Decoder.decode(stream, num_pipes: 1) |> Enum.take(2)
[]Reactions are currently unavailable