CsvToTable { public static List<List<String>> readCsv(Path csvPath, CsvPreference preference) { List<List<String>> allData = Lists.newArrayList(); Reader reader = null; try { reader = Files.newBufferedReader(csvPath, Charset.defaultCharset()); CsvListReader csv = new CsvListReader(reader, preference); List<String> line = null; while ((line = csv.read()) != null) { allData.add(line); } csv.close(); } catch (IOException e) { LOG.error("Problem reading CSV file {}", csvPath, e); } finally { try { if (reader != null) reader.close(); } catch (IOException ignore) { } } return allData; }  static List<List<String>> readCsv(Path csvPath, CsvPreference preference); static List<List<String>> readCsv(Path csvPath, char delimiter); static List<List<String>> readCsv(Path csvPath); static List<List<String>> transform(List<List<String>> data); static void writeAsTable(List<List<String>> data, Path tableFile); static final String HORIZONTAL; static final String VERTICAL; static final CsvPreference TABLE_PREFERENCE; }
@Test public void should_readCsv() throws URISyntaxException { URL f = Resources.getResource("data/inOut_vertical.csv"); List<List<String>> lists = CsvToTable.readCsv(Paths.get(f.toURI())); List<List<String>> expected = newArrayList( (List<String>) newArrayList("data", "t1", "t2"), newArrayList("in", "a", "aaa"), newArrayList("out", "a", "aaa")); assertThat(lists, equalTo(expected)); }