org.supercsv.io.ICsvListReader Java Examples
The following examples show how to use
org.supercsv.io.ICsvListReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MathUtil.java From powsybl-core with Mozilla Public License 2.0 | 6 votes |
public static Table<String, String, Float> parseMatrix(Reader reader) throws IOException { Table<String, String, Float> table = HashBasedTable.create(); try (ICsvListReader csvReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE)) { List<String> columnHeaders = csvReader.read(); List<String> row; while ((row = csvReader.read()) != null) { String rowHeader = row.get(0); for (int i = 1; i < row.size(); i++) { String columnHeader = columnHeaders.get(i); String value = row.get(i); table.put(rowHeader, columnHeader, value == null ? Float.NaN : Float.parseFloat(value)); } } } return table; }