Search in sources :

Example 1 with CSVInstanceWriter

use of eu.esdihumboldt.hale.io.csv.writer.internal.CSVInstanceWriter in project hale by halestudio.

the class CSVInstanceWriterTest method writeCsvToFile.

private boolean writeCsvToFile(File tmpFile, boolean skipFirstLine, Value sep, Value quo, Value esc, InstanceCollection instances) throws Exception {
    // set instances to xls instance writer
    InstanceWriter writer = new CSVInstanceWriter();
    IContentType contentType = HalePlatform.getContentTypeManager().getContentType("eu.esdihumboldt.hale.io.csv");
    writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(skipFirstLine));
    writer.setParameter(CSVSchemaReader.PARAM_SEPARATOR, sep);
    writer.setParameter(CSVSchemaReader.PARAM_QUOTE, quo);
    writer.setParameter(CSVSchemaReader.PARAM_ESCAPE, esc);
    writer.setInstances(instances);
    // write instances to a temporary CSV file
    writer.setTarget(new FileIOSupplier(tmpFile));
    writer.setContentType(contentType);
    IOReport report = writer.execute(null);
    return report.isSuccess();
}
Also used : InstanceWriter(eu.esdihumboldt.hale.common.instance.io.InstanceWriter) CSVInstanceWriter(eu.esdihumboldt.hale.io.csv.writer.internal.CSVInstanceWriter) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) IContentType(org.eclipse.core.runtime.content.IContentType) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) CSVInstanceWriter(eu.esdihumboldt.hale.io.csv.writer.internal.CSVInstanceWriter)

Aggregations

IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 InstanceWriter (eu.esdihumboldt.hale.common.instance.io.InstanceWriter)1 CSVInstanceWriter (eu.esdihumboldt.hale.io.csv.writer.internal.CSVInstanceWriter)1 IContentType (org.eclipse.core.runtime.content.IContentType)1