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

Missing last field in a decoded row #89

Closed
m3nadav opened this issue Aug 9, 2017 · 3 comments
Closed

Missing last field in a decoded row #89

m3nadav opened this issue Aug 9, 2017 · 3 comments

Comments

@m3nadav
Copy link

m3nadav commented Aug 9, 2017

I noticed something interesting, whenever i decode a row with a trailing space after a quoted last field it is like the field didn't exist.

The following test will fail on missing index 2

      val rawRow = """ "field1","field2","field3" """
      val retVal = rawRow.asCsvReader[List[String]](rfc).next match {
        case Result.Success(parsedLine)               => parsedLine
        case Result.Failure(ParseError.NoSuchElement) => List()
        case Result.Failure(_)                        => throw ParsingError(rawRow)
      }

      retVal.head shouldEqual "field1"
      retVal(1) shouldEqual "field2"
      retVal(2) shouldEqual "field3"

However if you remove the trailing space of rawRow it will work
val rawRow = """ "field1","field2","field3""""

Am i missing anything or doing it wrong?

@nrinaudo
Copy link
Owner

nrinaudo commented Aug 9, 2017

No, I don't think you're missing anything. This looks like a bug.

I have no idea how long it will take to fix - could be minutes, could be weeks. If you're in a hurry, can I suggest you try using one of the external engines?

@m3nadav
Copy link
Author

m3nadav commented Aug 9, 2017

for now i trim the string before decoding it, is there another reason to use an external engine?

@nrinaudo
Copy link
Owner

nrinaudo commented Aug 9, 2017

Two that I can think of. Jackson is faster than... well... pretty much everything.
And both Jackson and Apache Commons CSV are more battle-tested than kantan.csv's internal parser, for obvious reasons.

nrinaudo added a commit that referenced this issue Aug 9, 2017
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

2 participants