jackson-dataformats-text icon indicating copy to clipboard operation
jackson-dataformats-text copied to clipboard

FIX #45 Option to skip ending line break (csv)

Open mathieu-lavigne opened this issue 6 years ago • 4 comments

mathieu-lavigne avatar Oct 23 '17 08:10 mathieu-lavigne

Ok. Thank you for submitting this! It'd be great if logic would prevent outputting instead of trying to undo addition as undo seems bit error-prone. I'll see if that is doable.

cowtowncoder avatar Oct 24 '17 02:10 cowtowncoder

You're totally right @cowtowncoder. I tried that way first but it seemed to me to be more confusing. One reason is that you have to know when you reach the last line or not.

mathieu-lavigne avatar Oct 26 '17 07:10 mathieu-lavigne

wow, this is open for a very long time.... I actually do need this...

OmarHawk avatar Mar 17 '22 15:03 OmarHawk

It'd be good to resolve the conflict, could consider merging.

cowtowncoder avatar Mar 17 '22 18:03 cowtowncoder

@mathieu-lavigne Apologies for dropping the ball on this. I think this would work, as CsvEncoder.endRow() does guarantee that linefeed is not split on output buffer boundary. There may be some edge cases still (someone calling CsvGenerator.flush() at the end before close()...) but that is probably acceptable considering how difficult alternative is (that of trying to change how linefeed is added).

But I'd like one bigger change: instead of CsvSchema, I think this really works better as CsvGenerator.Feature. There's also need for a unit test or two.

With those I'd be happy to merge this for 2.17.

I realize you may not have time or interest after this delay; if not, I understand. And can then proceed with a new PR.

cowtowncoder avatar Dec 22 '23 04:12 cowtowncoder

Created new PR #453 to implement as generator feature.

Found couple of issues wrt implementation -- generator.flush() will prevent it from working, basically -- but aside from that works ok (added couple of basic tests).

cowtowncoder avatar Jan 15 '24 01:01 cowtowncoder