* @param resourceName Where to get the data.
* @return A matrix of the results.
* @throws IOException If there is an error reading the data
*/
private static Matrix readCsv(String resourceName) throws IOException {
Splitter onCommas = Splitter.on(",").trimResults(CharMatcher.anyOf(" \""));
Readable isr = new InputStreamReader(Resources.getResource(resourceName).openStream(), Charsets.UTF_8);
List<String> data = CharStreams.readLines(isr);
String first = data.get(0);
data = data.subList(1, data.size());
List<String> values = Lists.newArrayList(onCommas.split(first));
Matrix r = new DenseMatrix(data.size(), values.size());
int column = 0;
Map<String, Integer> labels = Maps.newHashMap();
for (String value : values) {
labels.put(value, column);
column++;
}
r.setColumnLabelBindings(labels);
int row = 0;
for (String line : data) {
column = 0;
values = Lists.newArrayList(onCommas.split(line));
for (String value : values) {
r.set(row, column, Double.parseDouble(value));
column++;
}
row++;