uniVocity / univocity-parsers

uniVocity-parsers is a suite of extremely fast and reliable parsers for Java. It provides a consistent interface for handling different file formats, and a solid framework for the development of new parsers.
914 stars 251 forks source link

How to append empty or null values without quote in CsvWriter #329

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi When i set settings.setQuoteAllFields(true); then all fields are quoted, this is logical, but can i set any settings NOT to apply quotes in empty or null fields?

For example, when i call String stringRow = writer.writeRowToString(new String[] {"null","","","123"}) the stringRow is "";"";"";"123"

but i need ;;;"123"

How can i set this?

jbax commented 5 years ago

Version 3.0.0 should have that covered as it will be easy to configure each column individually. I'll leave this issue open to let you know when it's ready.

EnricoMi commented 4 years ago

I think the question is how to get values quoted only if they are non-empty and non-null, not 'no quoting for the entire column', so something like:

1;"abc"
2;
3;null

for this table:

id value
1 "abc"
2 ""
3 NULL