@Test public void testGetCsvDataListMap() throws IOException { List<Map<String, String>> expectedDataListMap = Lists.newArrayList(); String[] columnHeaders = new String[4]; if (headerPresent) { columnHeaders = originalDataList.get(0); } else { for (int i = 0; i < columnHeaders.length; i++) { columnHeaders[i] = Integer.valueOf(i).toString(); } } for (String[] rowData : dataList) { Map<String, String> rowMap = Maps.newHashMap(); for (int i = 0; i < rowData.length; i++) { rowMap.put(columnHeaders[i], rowData[i]); } expectedDataListMap.add(rowMap); } List<Map<String, String>> actualDataListMap = CsvFiles.getCsvDataListMap(csvStringFile.getPath(), headerPresent); assertEquals(expectedDataListMap, actualDataListMap); }
public static List<Map<String, String>> getCsvDataListMap(String fileName, boolean headerPresent) throws IOException { final List<Map<String, String>> result = Lists.newArrayList(); new CsvReader(fileName, headerPresent) .processReader( (headers, line, lineNumber) -> { Map<String, String> data = Maps.newHashMap(); for (int i = 0; i < line.length; i++) { if (headers != null) { data.put(headers[i], line[i]); } else { data.put(i + "", line[i]); } } result.add(data); }); return result; }
CsvFiles { public static List<Map<String, String>> getCsvDataListMap(String fileName, boolean headerPresent) throws IOException { final List<Map<String, String>> result = Lists.newArrayList(); new CsvReader(fileName, headerPresent) .processReader( (headers, line, lineNumber) -> { Map<String, String> data = Maps.newHashMap(); for (int i = 0; i < line.length; i++) { if (headers != null) { data.put(headers[i], line[i]); } else { data.put(i + "", line[i]); } } result.add(data); }); return result; } }
CsvFiles { public static List<Map<String, String>> getCsvDataListMap(String fileName, boolean headerPresent) throws IOException { final List<Map<String, String>> result = Lists.newArrayList(); new CsvReader(fileName, headerPresent) .processReader( (headers, line, lineNumber) -> { Map<String, String> data = Maps.newHashMap(); for (int i = 0; i < line.length; i++) { if (headers != null) { data.put(headers[i], line[i]); } else { data.put(i + "", line[i]); } } result.add(data); }); return result; } private  CsvFiles(); }
CsvFiles { public static List<Map<String, String>> getCsvDataListMap(String fileName, boolean headerPresent) throws IOException { final List<Map<String, String>> result = Lists.newArrayList(); new CsvReader(fileName, headerPresent) .processReader( (headers, line, lineNumber) -> { Map<String, String> data = Maps.newHashMap(); for (int i = 0; i < line.length; i++) { if (headers != null) { data.put(headers[i], line[i]); } else { data.put(i + "", line[i]); } } result.add(data); }); return result; } private  CsvFiles(); static Map<String, String> getCsvDataMap(String fileName,
      final int key, final int value, boolean headerPresent); static Map<String, String> getCsvDataMap(String fileName, boolean headerPresent); static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent); static List<Map<String, String>> getCsvDataListMap(String fileName,
      boolean headerPresent); static List<String> getCsvDataByColumn(String fileName, final int column,
      boolean headerPresent); static List<String[]> getCsvDataArray(String fileName, boolean headerPresent); static List<String[]> getCsvDataArray(Reader csvReader, boolean headerPresent); static void writeCsv(List<String[]> csvData, String fileName); }
CsvFiles { public static List<Map<String, String>> getCsvDataListMap(String fileName, boolean headerPresent) throws IOException { final List<Map<String, String>> result = Lists.newArrayList(); new CsvReader(fileName, headerPresent) .processReader( (headers, line, lineNumber) -> { Map<String, String> data = Maps.newHashMap(); for (int i = 0; i < line.length; i++) { if (headers != null) { data.put(headers[i], line[i]); } else { data.put(i + "", line[i]); } } result.add(data); }); return result; } private  CsvFiles(); static Map<String, String> getCsvDataMap(String fileName,
      final int key, final int value, boolean headerPresent); static Map<String, String> getCsvDataMap(String fileName, boolean headerPresent); static Map<String, String[]> getCsvDataMapArray(String fileName, boolean headerPresent); static List<Map<String, String>> getCsvDataListMap(String fileName,
      boolean headerPresent); static List<String> getCsvDataByColumn(String fileName, final int column,
      boolean headerPresent); static List<String[]> getCsvDataArray(String fileName, boolean headerPresent); static List<String[]> getCsvDataArray(Reader csvReader, boolean headerPresent); static void writeCsv(List<String[]> csvData, String fileName);  }