Example #1
0
  /**
   * Reads floating values from a CSV file and returns them in an array.
   *
   * @param state
   * @param terminalFileCSV the file with the float values
   * @return an array with all of the float values in the file
   */
  public double[] getRawTimeSeriesValuesFromCSVfile(
      EvolutionState state, CsvReader terminalFileCSV) {
    // expect the CSV file to contain only float values ...
    Vector rawValues = new Vector(100);
    try {
      while (terminalFileCSV.readRecord()) {
        for (int i = 0; i < terminalFileCSV.getColumnCount(); i++)
          rawValues.add(terminalFileCSV.get(i));
      }
    } catch (IOException e) {
      state.output.fatal("The file with time series raw values failed when reading records. " + e);
    }
    // convert the vector into an array
    double rvArray[] = new double[rawValues.size()];
    for (int i = 0; i < rvArray.length; i++)
      rvArray[i] = Double.parseDouble((String) rawValues.elementAt(i));

    return rvArray;
  }