tototoshi / scala-csv

CSV Reader/Writer for Scala
Other
697 stars 141 forks source link

Add feature to ignore surrounding spaces #91

Open dportabella opened 8 years ago

dportabella commented 8 years ago

I have this input: aa, "bb,cc", dd and I expect this list:

aa
bb,cc
dd

Using the DefaultCSVFormat, this input fails with MalformedCSVException.

using this formatter:

implicit object MyFormat extends DefaultCSVFormat {
  override val escapeChar = '\\'
}

then I get this list:

aa
 "bb
cc"
dd

so, the parsing is invalid when a delimiter is inside a quote. also, it should ignore spaces between fields.

dportabella commented 8 years ago

Note: the previous example works as expected using the apache commons CSV parser:

    org.apache.commons.csv.CSVParser.parse(
      new File(file), 
      StandardCharsets.UTF_8,
      CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true))
devmanhinton commented 6 years ago

+1 On this