Search in sources :

Example 1 with TableStoreForCsvFile

use of org.molgenis.emx2.io.tablestore.TableStoreForCsvFile in project molgenis-emx2 by molgenis.

the class TestColumnTypeIsFile method testCsvShouldNotIncludeFileColumns.

@Test
public void testCsvShouldNotIncludeFileColumns() throws IOException {
    Path tmp = Files.createTempDirectory(null);
    Path csvFile = tmp.resolve("User.csv");
    MolgenisIO.toExcelFile(csvFile, schema.getTable("User"));
    TableStore store = new TableStoreForCsvFile(csvFile);
    assertFalse(store.readTable("User").iterator().next().getColumnNames().contains("picture"));
}
Also used : Path(java.nio.file.Path) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) TableStore(org.molgenis.emx2.io.tablestore.TableStore) Test(org.junit.Test)

Example 2 with TableStoreForCsvFile

use of org.molgenis.emx2.io.tablestore.TableStoreForCsvFile in project molgenis-emx2 by molgenis.

the class TestTypesImport method testTsvTypeCast.

@Test
public void testTsvTypeCast() {
    ClassLoader classLoader = getClass().getClassLoader();
    Path path = new File(classLoader.getResource("TypeTest.tsv").getFile()).toPath();
    TableStore store = new TableStoreForCsvFile(path);
    for (Row r : store.readTable("Sheet1")) {
        assertEquals("1", r.getString("column1"));
        assertEquals("2", r.getString("column2"));
    }
}
Also used : Path(java.nio.file.Path) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) Row(org.molgenis.emx2.Row) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) File(java.io.File) TableStoreForXlsxFile(org.molgenis.emx2.io.tablestore.TableStoreForXlsxFile) TableStore(org.molgenis.emx2.io.tablestore.TableStore) Test(org.junit.Test)

Example 3 with TableStoreForCsvFile

use of org.molgenis.emx2.io.tablestore.TableStoreForCsvFile in project molgenis-emx2 by molgenis.

the class TestTypesImport method testSemiColonTypeCast.

@Test
public void testSemiColonTypeCast() {
    ClassLoader classLoader = getClass().getClassLoader();
    Path path = new File(classLoader.getResource("TypeTestSemiColon.csv").getFile()).toPath();
    TableStore store = new TableStoreForCsvFile(path);
    for (Row r : store.readTable("Sheet1")) {
        assertEquals("a", r.getString("string"));
        assertEquals("b", r.getStringArray("string_array")[1]);
        assertEquals("a,b", r.getStringArray("string_array2")[0]);
    }
}
Also used : Path(java.nio.file.Path) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) Row(org.molgenis.emx2.Row) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) File(java.io.File) TableStoreForXlsxFile(org.molgenis.emx2.io.tablestore.TableStoreForXlsxFile) TableStore(org.molgenis.emx2.io.tablestore.TableStore) Test(org.junit.Test)

Example 4 with TableStoreForCsvFile

use of org.molgenis.emx2.io.tablestore.TableStoreForCsvFile in project molgenis-emx2 by molgenis.

the class TestTypesImport method testCsvTypesCast.

@Test
public void testCsvTypesCast() {
    ClassLoader classLoader = getClass().getClassLoader();
    Path path = new File(classLoader.getResource("TypeTest.csv").getFile()).toPath();
    TableStore store = new TableStoreForCsvFile(path);
    for (Row r : store.readTable("Sheet1")) {
        assertEquals("Respiratory, allergy and skin characteristics", r.getStringArray("string_array")[0]);
        assertEquals("Respiratory, allergy and skin characteristics", r.getStringArray("string_array2")[0]);
        assertEquals("Respiratory, allergy and skin characteristics2", r.getStringArray("string_array2")[1]);
    }
}
Also used : Path(java.nio.file.Path) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) Row(org.molgenis.emx2.Row) TableStoreForCsvFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvFile) File(java.io.File) TableStoreForXlsxFile(org.molgenis.emx2.io.tablestore.TableStoreForXlsxFile) TableStore(org.molgenis.emx2.io.tablestore.TableStore) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)4 Test (org.junit.Test)4 TableStore (org.molgenis.emx2.io.tablestore.TableStore)4 TableStoreForCsvFile (org.molgenis.emx2.io.tablestore.TableStoreForCsvFile)4 File (java.io.File)3 Row (org.molgenis.emx2.Row)3 TableStoreForXlsxFile (org.molgenis.emx2.io.tablestore.TableStoreForXlsxFile)3