dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
767 stars 51 forks source link

writing a row with a comma in it doesn't appear to be escaped #10

Closed rozap closed 7 years ago

rozap commented 7 years ago

I'd think a row with a comma in it would get quoted, but it doesn't seem to. I might be misunderstanding things entirely, but I've taken the example from here: https://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules

Behaviour:

iex> NimbleCSV.RFC4180.dump_to_iodata([[1997, "Ford", "E350", "Super, luxurious truck"]])
[["1997", 44, "Ford", 44, "E350", 44, "Super, luxurious truck", 10]]

What I'd expect

iex> NimbleCSV.RFC4180.dump_to_iodata([[1997, "Ford", "E350", "Super, luxurious truck"]])
[["1997", 44, "Ford", 44, "E350", 44, "\"Super, luxurious truck\"", 10]]

Does nimblecsv expect commas in values will already be quoted? Or is this a bug?

josevalim commented 7 years ago

@rozap it does look like a bug.

josevalim commented 7 years ago

v0.1.1 is out with a fix.