use of eu.esdihumboldt.hale.io.csv.reader.internal.CSVInstanceReader in project hale by halestudio.
the class CSVInstanceReaderTest method readCSVInstances.
private InstanceCollection readCSVInstances(String sourceLocation, String typeName, boolean skipFirst, Schema sourceSchema, String seperator, String quote, String escape, String decimal) throws Exception {
InstanceReader instanceReader = new CSVInstanceReader();
instanceReader.setSource(new DefaultInputSupplier(getClass().getResource(sourceLocation).toURI()));
instanceReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of(typeName));
instanceReader.setParameter(CommonSchemaConstants.PARAM_SKIP_FIRST_LINE, Value.of(skipFirst));
instanceReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, Value.of(seperator));
instanceReader.setParameter(CSVSchemaReader.PARAM_QUOTE, Value.of(quote));
instanceReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, Value.of(escape));
instanceReader.setParameter(CSVSchemaReader.PARAM_DECIMAL, Value.of(decimal));
instanceReader.setSourceSchema(sourceSchema);
// Test instances
IOReport report = instanceReader.execute(null);
assertTrue("Data import was not successfull.", report.isSuccess());
return instanceReader.getInstances();
}
Aggregations