agourlay / json-2-csv

Transforms JSON collections into CSV files.
MIT License
10 stars 7 forks source link

Triple quotes around strings #2

Closed jlandahl closed 7 years ago

jlandahl commented 7 years ago

Strings in the CSV output produced by Json2Csv.convert are surrounded by triple quotes, which is not standard and not understood by CSV readers I'm using to read the output (e.g. Spark's CSV reader). The result is that all strings end up with the triple quotes included in the values when read.

Here's a simple demonstration:

object Foo extends App {
  import com.github.agourlay.json2Csv.Json2Csv
  import java.io.ByteArrayOutputStream

  val json = """{"a": "abcdefg", "b": "hijklmnop"}"""
  val baos = new ByteArrayOutputStream
  Json2Csv.convert(Stream(json), baos)
  println(baos.toString("UTF8"))
}

The output is:

a,b
"""abcdefg""","""hijklmnop"""
agourlay commented 7 years ago

Thank you for opening this issue, this is indeed something that should be improved.

I just wrote a fix and released version 0.3.0, give it a try and tell me how it goes 😃

agourlay commented 7 years ago

closing due to inactivity