Search in sources :

Example 16 with CsvWriterSettings

use of com.univocity.parsers.csv.CsvWriterSettings in project symja_android_library by axkr.

the class CsvWriter method createSettings.

protected static CsvWriterSettings createSettings(CsvWriteOptions options) {
    CsvWriterSettings settings = new CsvWriterSettings();
    // Sets the character sequence to write for the values that are null.
    settings.setNullValue(nullValue);
    if (options.separator() != null) {
        settings.getFormat().setDelimiter(options.separator());
    }
    if (options.quoteChar() != null) {
        settings.getFormat().setQuote(options.quoteChar());
    }
    if (options.escapeChar() != null) {
        settings.getFormat().setQuoteEscape(options.escapeChar());
    }
    if (options.lineEnd() != null) {
        settings.getFormat().setLineSeparator(options.lineEnd());
    }
    settings.setIgnoreLeadingWhitespaces(options.ignoreLeadingWhitespaces());
    settings.setIgnoreTrailingWhitespaces(options.ignoreTrailingWhitespaces());
    // writes empty lines as well.
    settings.setSkipEmptyLines(false);
    settings.setQuoteAllFields(options.quoteAllFields());
    return settings;
}
Also used : CsvWriterSettings(com.univocity.parsers.csv.CsvWriterSettings)

Aggregations

CsvWriterSettings (com.univocity.parsers.csv.CsvWriterSettings)16 CsvWriter (com.univocity.parsers.csv.CsvWriter)7 CsvFormat (com.univocity.parsers.csv.CsvFormat)5 CsvParserSettings (com.univocity.parsers.csv.CsvParserSettings)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 Writer (java.io.Writer)2 PolicyStats (com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats)1 LEGACY_TEXT (com.powsybl.psse.model.io.FileFormat.LEGACY_TEXT)1 BeanWriterProcessor (com.univocity.parsers.common.processor.BeanWriterProcessor)1 CsvParser (com.univocity.parsers.csv.CsvParser)1 java.awt (java.awt)1 BufferedImage (java.awt.image.BufferedImage)1 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 StringWriter (java.io.StringWriter)1 StandardCharsets (java.nio.charset.StandardCharsets)1 DecimalFormat (java.text.DecimalFormat)1 java.util (java.util)1 List (java.util.List)1