mekomsolutions/openmrs-module-initializer

CSV Parser should ignore blank lines at end of file

Opened this issue · 2 comments

Minor annoyance/feature request, but if you have blank lines at the end of a csv file, the parser throws an exception saying it it unable to parse those lines. It would be nice if the the parser could just ignore those lines without errorring.

@Ruhanga @mseaton @rbuisson

Something like this could be done after this block.

Or we could perhaps overload CSVReader#readNext().


I'm not sure anymore why things are how they are now, but it might have been more or less intentional actually, in order to detect blank lines here and there (including within the pack, not just at the end of the file) and encourage implementers to keep their CSV clean and tidy. Happy to change this though.

We are already trimming and checking for empty values for each cell entry here. We could just retain a boolean indicating if any non-empty values were found for a row, and if not, return null.