Appendium / flatpack

CSV/Tab Delimited and Fixed Length Parser and Writer
http://flatpack.sf.net
Apache License 2.0
57 stars 20 forks source link

needsQuoting in DelimiterWriter.write is determined incorrectly #54

Open brentleeper opened 4 years ago

brentleeper commented 4 years ago

Currently:

final boolean needsQuoting = stringValue.indexOf(delimiter) != -1 // || foundQualifier // || stringValue.indexOf('\n') != -1;

Should be:

final boolean needsQuoting = foundQualifier && (stringValue.indexOf(delimiter) != 1 || stringValue.indexOf("\n") != 1);

Because:

If the qualifier is not found, then you cannot write the qualifier ever.

brentleeper commented 4 years ago

Currently, even if I set the qualifier in the DelimiterWriterFactory to FPConstants.NO_QUALIFIER, there is still a case where the qualifier will be written. This is incorrect.

benoitx commented 4 years ago

Hi

May I ask you to provide a unit test for this and I will fix the issue.

Thanks a lot, that would be great.

Benoit

On Tue, 24 Mar 2020 at 17:32, brentleeper notifications@github.com wrote:

Currently, even if I set the qualifier in the DelimiterWriterFactory to FPConstants.NO_QUALIFIER, there is still a case where the qualifier will be written. This is incorrect.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Appendium/flatpack/issues/54#issuecomment-603393116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB542KIWNILJKHAPXAGG5TRJDVDXANCNFSM4LS3IEZA .

brentleeper commented 4 years ago

First can you help me to understand the purpose of foundQualifier, just to make sure I am understanding correctly