use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class ParserFactoryLocalTest method parseCompressedDataSet.
@Test
public void parseCompressedDataSet() throws IOException {
LabeledCSVParser labeledCSVParser = null;
try {
labeledCSVParser = new ParserFactoryLocal().createParser(StudyImporterForSimons.MISSISSIPPI_ALABAMA_DATA_SOURCE, "UTF-8");
labeledCSVParser.getLine();
assertFirstLine(labeledCSVParser);
labeledCSVParser.getLine();
assertSecondLine(labeledCSVParser);
} finally {
if (null != labeledCSVParser) {
labeledCSVParser.close();
}
}
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class StudyImporterFelderTest method convertToTSVWithHeader.
@Test
public void convertToTSVWithHeader() throws IOException {
File felder = File.createTempFile("felder", ".tsv");
felder.deleteOnExit();
OutputStream os = new FileOutputStream(felder);
IOUtils.write(HEADER + "\n", os);
IOUtils.copy(convertToTSV(getClass().getResourceAsStream("felder/BIRDS.BDT")), os);
LabeledCSVParser parser = CSVTSVUtil.createLabeledCSVParser(new FileInputStream(felder));
parser.changeDelimiter('\t');
assertThat(parser.getLabels(), is(FIELDS));
assertThat(parser.getLine(), is(notNullValue()));
assertThat(parser.getValueByLabel("Author"), is("*Dawson, W. L."));
assertThat(parser.getValueByLabel("species"), is("_fulicarius_"));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthParserImplTest method parseNoLengthUnavailable.
@Test
public void parseNoLengthUnavailable() throws IOException, StudyImporterException {
LengthParserImpl parser = new LengthParserImpl("bla");
LabeledCSVParser csvParser = initParser();
assertNull(parser.parseLengthInMm(csvParser));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthParserImplTest method parseLengthMalformed.
@Test(expected = StudyImporterException.class)
public void parseLengthMalformed() throws IOException, StudyImporterException {
LengthParserImpl parser = new LengthParserImpl("johnny");
LabeledCSVParser csvParser = new TestParserFactory("johnny\nAINTRIGHT\n324\n").createParser("aStudy", "UTF-8");
csvParser.getLine();
parser.parseLengthInMm(csvParser);
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class LengthParserImplTest method parse.
@Test
public void parse() throws IOException, StudyImporterException {
LengthParserImpl parser = new LengthParserImpl("johnny");
LabeledCSVParser csvParser = initParser();
assertEquals(123.0d, parser.parseLengthInMm(csvParser));
}
Aggregations