Search in sources :

Example 76 with LabeledCSVParser

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();
        }
    }
}
Also used : LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Test(org.junit.Test)

Example 77 with LabeledCSVParser

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_"));
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 78 with LabeledCSVParser

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));
}
Also used : LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Test(org.junit.Test)

Example 79 with LabeledCSVParser

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);
}
Also used : LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Test(org.junit.Test)

Example 80 with LabeledCSVParser

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));
}
Also used : LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) Test(org.junit.Test)

Aggregations

LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)82 IOException (java.io.IOException)40 Test (org.junit.Test)31 Study (org.eol.globi.domain.Study)24 StudyImpl (org.eol.globi.domain.StudyImpl)17 Specimen (org.eol.globi.domain.Specimen)15 HashMap (java.util.HashMap)13 ArrayList (java.util.ArrayList)12 Location (org.eol.globi.domain.Location)12 TaxonImpl (org.eol.globi.domain.TaxonImpl)12 CSVParser (com.Ostermiller.util.CSVParser)10 StringReader (java.io.StringReader)8 LocationImpl (org.eol.globi.domain.LocationImpl)8 Taxon (org.eol.globi.domain.Taxon)8 InteractType (org.eol.globi.domain.InteractType)7 File (java.io.File)6 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)6 Date (java.util.Date)6 List (java.util.List)6