CsvToTable { public static List<List<String>> transform(List<List<String>> data) { List<List<String>> allData = Lists.newArrayList(); for (int i = 0; i < data.get(0).size(); i++) { allData.add(new ArrayList<String>()); } for (List<String> row : data) { for (int i = 0; i < row.size(); i++) { allData.get(i).add(row.get(i)); } } 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_transformTable() { List<List<String>> data = newArrayList(); String[] rest = {"1", "2", "3"}; data.add(asList("A", "b", rest)); data.add(asList("c", "d", rest)); List<List<String>> expected = newArrayList( (List<String>) newArrayList("A", "c"), newArrayList("b", "d"), newArrayList("1", "1"), newArrayList("2", "2"), newArrayList("3", "3")); assertThat(CsvToTable.transform(data), equalTo(expected)); }