Skip to content

Commit b8e5a4a

Browse files
committed
Fix problem with the last cell in the last row being escaped and followed by whitespace.
Closes #89.
1 parent 59604b9 commit b8e5a4a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/src/main/scala/kantan/csv/engine/InternalReader.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ private[engine] class InternalReader private (val data: Reader, val conf: CsvCon
156156

157157
case _ if c.isWhitespace
158158
if(hasNextChar) escapedCellEnd(nextChar())
159-
else InternalReader.EOF
159+
else {
160+
endCell()
161+
InternalReader.EOF
162+
}
160163

161164
case conf.quote escapedCell(true)
162165

core/src/test/scala/kantan/csv/engine/InternalReaderRegressionTests.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ class InternalReaderRegressionTests extends FunSuite {
3838
test("If the last cell of the last row is a quoted empty string, it should still be read (#88)") {
3939
assert("\"\"".unsafeReadCsv[List, List[String]](rfc) == List(List("")))
4040
}
41+
42+
test("if the last cell of a row is quoted and followed by a space, it should still be read (#89)") {
43+
assert(""" "field1","field2","field3" """.unsafeReadCsv[List, List[String]](rfc) ==
44+
List(List("field1", "field2", "field3 ")))
45+
}
4146
}

0 commit comments

Comments
 (0)