openmrs-module-initializer icon indicating copy to clipboard operation
openmrs-module-initializer copied to clipboard

CSV Parser should ignore blank lines at end of file

Open mogoodrich opened this issue 1 year ago • 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

mogoodrich avatar Jun 06 '24 20:06 mogoodrich

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.

mks-d avatar Jul 02 '24 05:07 mks-d

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.

mseaton avatar Jul 02 '24 11:07 mseaton