public static YailList fromCsvTable(String csvString) throws Exception { CsvParser csvParser = new CsvParser(new StringReader(csvString)); ArrayList<YailList> csvList = new ArrayList<YailList>(); while (csvParser.hasNext()) { csvList.add(YailList.makeList(csvParser.next())); } csvParser.throwAnyProblem(); return YailList.makeList(csvList); }
public static YailList fromCsvRow(String csvString) throws Exception { CsvParser csvParser = new CsvParser(new StringReader(csvString)); if (csvParser.hasNext()) { YailList row = YailList.makeList(csvParser.next()); if (csvParser.hasNext()) { // more than one row is an error throw new IllegalArgumentException("CSV text has multiple rows. Expected just one row."); } csvParser.throwAnyProblem(); return row; } throw new IllegalArgumentException("CSV text cannot be parsed as a row."); }