Example usage for org.apache.commons.csv CSVFormat format

List of usage examples for org.apache.commons.csv CSVFormat format

Introduction

In this page you can find the example usage for org.apache.commons.csv CSVFormat format.

Prototype

public String format(final Object... values) 

Source Link

Document

Formats the specified values.

Usage

From source file:notaql.engines.csv.CSVEngineEvaluator.java

/**
 * Stores the resulting rows to disk./*from  w  ww. j  av  a2 s.c o m*/
 *
 * @param result
 */
@Override
public void store(JavaRDD<ObjectValue> result) {
    final JavaSparkContext sc = NotaQL.SparkFactory.getSparkContext();

    final String[] header = getHeader(result);
    final CSVFormat format = CSVFormat.DEFAULT;

    final JavaRDD<String> headerRDD = sc.parallelize(Arrays.asList(format.format(header)));

    final JavaRDD<String> lines = result.map(o -> ValueConverter.convertFromNotaQL(o, header))
            .map(strings -> format.format(strings.toArray()));

    sc.union(headerRDD, lines).saveAsTextFile(path);
}