Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot write and read back arbitrary data using arbitrary CSVFormat #98

Open
jedesah opened this issue Jan 30, 2017 · 0 comments
Open

Comments

@jedesah
Copy link

jedesah commented Jan 30, 2017

Example of an offending scenario:

Given the following csv format:

val format = new DefaultCSVFormat {
  override val quoteChar: Char = 'd'
  override val delimiter: Char = 'u'
  override val escapeChar: Char = 'e'
}

I'll write this in pseudocode to keep things simple:

csv.write(format, List("foo", "true")) === "fooudtrued"
csv.read(format, "fooudtrued") === -\/("Malformed input")
// This works
csv.read(format, "fooudtrueed") === \/-(List("foo", "true"))

I am not sure whether the writer is at fault for not escaping the escape character or if it's the parser which should not interpret the escape character as such inside of a quote.

This might seem like a little bit of an academic exercise given the unlikely csv format, but it's causing test failures for us since we have scalacheck properties that generate arbitrary CSVFormat.

I can submit a pull request with a scalacheck property that makes sure that for any Arbitrary[List[List[String]]] and Arbitrary[CSVFormat], data == read(write(data)) is true, but as mentioned in my example above, I'm not sure whether the fix should be in the Parser or the Writer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant