xlson / groovycsv

A simple CSV parsing library for groovy
http://xlson.com/groovycsv/
Other
139 stars 32 forks source link

exception when the csv contains an empty line #29

Closed mrdfuse closed 7 years ago

mrdfuse commented 10 years ago

When the CSV file contains an empty line between some lines, the following exception is thrown: java.lang.ArrayIndexOutOfBoundsException: 1 at com.xlson.groovycsv.PropertyMapper$_toString_closure1.doCall(PropertyMapper.groovy:67) at com.xlson.groovycsv.PropertyMapper.toString(PropertyMapper.groovy:67) at ConsoleScript1.run(ConsoleScript1:7)

xlson commented 9 years ago

It'd probably be a good idea to throw a nicer exception in cases like these. When it comes to the actual problem I'd suggest stripping empty lines out of the file first. As I see it it's an error in the data and not in the parsing.

mrdfuse commented 9 years ago

While there is no real standard for CSV, and https://tools.ietf.org/html/rfc4180 doesn't mention anything about blank lines, most if not all parsers handle it quietly (and not as EOF). Doesn't matter to me, I can't even remember in what context I encountered this bug :)

xlson commented 9 years ago

I know how that feels :) We'll see, perhaps I'll put something in there to handle it anyway. Can't really see a cost. Oh, and thanks for the issue, always much appreciated.

mrdfuse commented 9 years ago

Yeah no problem, logging them is easy, it's the solving that requires the effort :)