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();
}
Aggregations