package org.opencompare.api.java.io;

import com.opencsv.CSVWriter;
import org.opencompare.api.java.*;

import java.io.IOException;
import java.io.StringWriter;
import java.util.*;

/**
 * Created by gbecan on 3/19/15.
 */
public class CSVExporter implements PCMExporter {

    PCMMetadata currentMetadata = null;

    @Override
    public String export(PCMContainer container) {
        currentMetadata = container.getMetadata();
        return export(container.getPcm());
    }

    private String export(PCM pcm) {
        StringWriter stringWriter = new StringWriter();
        CSVWriter csvWriter = new CSVWriter(stringWriter);

        // Export features
        if (currentMetadata  == null) currentMetadata = new PCMMetadata(pcm);

        List<Feature> features = currentMetadata.getSortedFeatures();
        List<Product> products = currentMetadata.getSortedProducts();
        List<String> featureLine = new ArrayList<>();

        featureLine.add("Product");

        for (Feature feature : features) {
            featureLine.add(feature.getName());
        }

        csvWriter.writeNext(featureLine.toArray(new String[featureLine.size()]));

        // Export products
        for (Product product : products) {
            List<String> productLine = new ArrayList<>();

            productLine.add(product.getName());
            for (Feature feature : features) {
                Cell cell = product.findCell(feature);
                if (cell == null) {
                    productLine.add("");
                } else {
                    productLine.add(cell.getContent());
                }

            }

            csvWriter.writeNext(productLine.toArray(new String[productLine.size()]));
        }


        try {
            csvWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return stringWriter.toString();
    }
}

package org.opencompare.api.java.io;

import com.opencsv.CSVWriter;
import org.opencompare.api.java.*;

import java.io.IOException;
import java.io.StringWriter;
import java.util.*;

/**
 * Created by gbecan on 3/19/15.
 */
public class CSVExporter implements PCMExporter {

    PCMMetadata currentMetadata = null;
    char separator = ',';
    char quote = '"';

    public CSVExporter setSeparator(char separator) {
        this.separator = separator;
        return this;
    }

    public CSVExporter setQuote(char quote) {
        this.quote = quote;
        return this;
    }

    @Override
    public String export(PCMContainer container) {
        currentMetadata = container.getMetadata();
        return export(container.getPcm());
    }

    private String export(PCM pcm) {
        StringWriter stringWriter = new StringWriter();
        CSVWriter csvWriter = new CSVWriter(stringWriter, separator, quote);

        // Export features
        if (currentMetadata  == null) currentMetadata = new PCMMetadata(pcm);

        List<Feature> features = currentMetadata.getSortedFeatures();
        List<Product> products = currentMetadata.getSortedProducts();
        List<String> featureLine = new ArrayList<>();

        featureLine.add("Product");

        for (Feature feature : features) {
            featureLine.add(feature.getName());
        }

        csvWriter.writeNext(featureLine.toArray(new String[featureLine.size()]));

        // Export products
        for (Product product : products) {
            List<String> productLine = new ArrayList<>();

            productLine.add(product.getName());
            for (Feature feature : features) {
                Cell cell = product.findCell(feature);
                if (cell == null) {
                    productLine.add("");
                } else {
                    productLine.add(cell.getContent());
                }

            }

            csvWriter.writeNext(productLine.toArray(new String[productLine.size()]));
        }


        try {
            csvWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return stringWriter.toString();
    }
}

Add separator and quote option in CSVExporter