Req.CSV (req v0.8.0-rc.0)

Copy Markdown View Source

CSV decoding using nimble_csv.

Req.Decode can use this module for .csv and text/csv responses when the :csv decoder is enabled via the :decoders option.

Examples

Req.get!(url, decoders: [:csv]).body
#=> [["x", "y"], ["1", "2"], ["3", "4"]]

Req.CSV does NOT currently do streaming decoding:

Req.stream(
  url,
  nil,
  fn data, _resp, acc ->
    IO.inspect(data)
    {:cont, acc}
  end,
  decoders: [:csv]
)
# Output: "x,y\r\n"
# Output: "1,2\r\n"
# Output: "3,4\r\n"