@Test public void read1() throws IOException { Point2DDataset dataset = CommaSeparatedValueIO.read("x,y\n0,0\n2,0.1\n4,0.2\n1,0.3\n3,0.4\n5,0.5"); assertThat(dataset.getCount(), equalTo(6)); assertThat(dataset.getXValues(), equalTo((ListNumber) new ArrayDouble(0,2,4,1,3,5))); assertThat(dataset.getYValues(), equalTo((ListNumber) new ArrayDouble(0,0.1,0.2,0.3,0.4,0.5))); }
public static Point2DDataset read(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line = br.readLine(); CircularBufferDouble xValues = new CircularBufferDouble(Integer.MAX_VALUE); CircularBufferDouble yValues = new CircularBufferDouble(Integer.MAX_VALUE); while ((line = br.readLine()) != null) { String[] tokens = line.split(","); if (tokens.length != 2) { throw new IllegalArgumentException("Each line must have two values"); } double xValue = Double.parseDouble(tokens[0]); double yValue = Double.parseDouble(tokens[1]); xValues.addDouble(xValue); yValues.addDouble(yValue); } return Point2DDatasets.lineData(xValues, yValues); }
CommaSeparatedValueIO { public static Point2DDataset read(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line = br.readLine(); CircularBufferDouble xValues = new CircularBufferDouble(Integer.MAX_VALUE); CircularBufferDouble yValues = new CircularBufferDouble(Integer.MAX_VALUE); while ((line = br.readLine()) != null) { String[] tokens = line.split(","); if (tokens.length != 2) { throw new IllegalArgumentException("Each line must have two values"); } double xValue = Double.parseDouble(tokens[0]); double yValue = Double.parseDouble(tokens[1]); xValues.addDouble(xValue); yValues.addDouble(yValue); } return Point2DDatasets.lineData(xValues, yValues); } }
CommaSeparatedValueIO { public static Point2DDataset read(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line = br.readLine(); CircularBufferDouble xValues = new CircularBufferDouble(Integer.MAX_VALUE); CircularBufferDouble yValues = new CircularBufferDouble(Integer.MAX_VALUE); while ((line = br.readLine()) != null) { String[] tokens = line.split(","); if (tokens.length != 2) { throw new IllegalArgumentException("Each line must have two values"); } double xValue = Double.parseDouble(tokens[0]); double yValue = Double.parseDouble(tokens[1]); xValues.addDouble(xValue); yValues.addDouble(yValue); } return Point2DDatasets.lineData(xValues, yValues); }  }
CommaSeparatedValueIO { public static Point2DDataset read(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line = br.readLine(); CircularBufferDouble xValues = new CircularBufferDouble(Integer.MAX_VALUE); CircularBufferDouble yValues = new CircularBufferDouble(Integer.MAX_VALUE); while ((line = br.readLine()) != null) { String[] tokens = line.split(","); if (tokens.length != 2) { throw new IllegalArgumentException("Each line must have two values"); } double xValue = Double.parseDouble(tokens[0]); double yValue = Double.parseDouble(tokens[1]); xValues.addDouble(xValue); yValues.addDouble(yValue); } return Point2DDatasets.lineData(xValues, yValues); }  static void write(Point2DDataset dataset, Writer writer); static String write(Point2DDataset dataset); static Point2DDataset read(Reader reader); static Point2DDataset read(String string); }
CommaSeparatedValueIO { public static Point2DDataset read(Reader reader) throws IOException { BufferedReader br = new BufferedReader(reader); String line = br.readLine(); CircularBufferDouble xValues = new CircularBufferDouble(Integer.MAX_VALUE); CircularBufferDouble yValues = new CircularBufferDouble(Integer.MAX_VALUE); while ((line = br.readLine()) != null) { String[] tokens = line.split(","); if (tokens.length != 2) { throw new IllegalArgumentException("Each line must have two values"); } double xValue = Double.parseDouble(tokens[0]); double yValue = Double.parseDouble(tokens[1]); xValues.addDouble(xValue); yValues.addDouble(yValue); } return Point2DDatasets.lineData(xValues, yValues); }  static void write(Point2DDataset dataset, Writer writer); static String write(Point2DDataset dataset); static Point2DDataset read(Reader reader); static Point2DDataset read(String string);  }