/**
   * Convert an external file format, such as CSV, to the Encog binary training format.
   *
   * @param binaryFile The binary file to create.
   */
  public void external2Binary(final File binaryFile) {

    status.report(0, 0, "Importing to binary file: " + binaryFile.toString());

    EncogEGBFile egb = new EncogEGBFile(binaryFile);

    egb.create(codec.getInputSize(), codec.getIdealSize());

    double[] input = new double[this.codec.getInputSize()];
    double[] ideal = new double[this.codec.getIdealSize()];

    this.codec.prepareRead();

    int index = 3;
    int currentRecord = 0;
    int lastUpdate = 0;
    double[] significance = new double[1];

    while (codec.read(input, ideal, significance)) {

      egb.write(input);
      egb.write(ideal);

      index += input.length;
      index += ideal.length;
      currentRecord++;
      lastUpdate++;
      if (lastUpdate >= 10000) {
        lastUpdate = 0;
        this.status.report(0, currentRecord, "Importing...");
      }

      egb.write(significance[0]);
    }

    egb.close();
    this.codec.close();
    status.report(0, 0, "Done importing to binary file: " + binaryFile.toString());
  }
  /**
   * Convert an Encog binary file to an external form, such as CSV.
   *
   * @param binaryFile THe binary file to use.
   */
  public void binary2External(final File binaryFile) {
    status.report(0, 0, "Exporting binary file: " + binaryFile.toString());

    EncogEGBFile egb = new EncogEGBFile(binaryFile);
    egb.open();

    this.codec.prepareWrite(egb.getNumberOfRecords(), egb.getInputCount(), egb.getIdealCount());

    int inputCount = egb.getInputCount();
    int idealCount = egb.getIdealCount();

    double[] input = new double[inputCount];
    double[] ideal = new double[idealCount];

    int currentRecord = 0;
    int lastUpdate = 0;

    // now load the data
    for (int i = 0; i < egb.getNumberOfRecords(); i++) {

      for (int j = 0; j < inputCount; j++) {
        input[j] = egb.read();
      }

      for (int j = 0; j < idealCount; j++) {
        ideal[j] = egb.read();
      }

      double significance = egb.read();

      this.codec.write(input, ideal, significance);

      currentRecord++;
      lastUpdate++;
      if (lastUpdate >= 10000) {
        lastUpdate = 0;
        this.status.report(egb.getNumberOfRecords(), currentRecord, "Exporting...");
      }
    }

    egb.close();
    this.codec.close();
    status.report(0, 0, "Done exporting binary file: " + binaryFile.toString());
  }