org.encog.ml.data.buffer.codec

## Class CSVDataCODEC

- java.lang.Object
- - org.encog.ml.data.buffer.codec.CSVDataCODEC

- All Implemented Interfaces:
    DataSetCODEC

      public class CSVDataCODEC
      extends Object
      implements DataSetCODEC

  A CODEC used to read/write data from/to a CSV data file. There are two constructors provided, one is for reading, the other for writing. Make sure you use the correct one for your intended purpose. This CODEC is typically used with the BinaryDataLoader, to load external data into the Encog binary training format.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CSVDataCODEC(File theFile, CSVFormat theFormat, boolean theExpectSignificance)` Constructor to create CSV from binary..
    `CSVDataCODEC(File theFile, CSVFormat theFormat, boolean theHeaders, int theInputCount, int theIdealCount, boolean theExpectSignificance)` Create a CODEC to load data from CSV to binary.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close any open files.
    `int` | `getIdealSize()`
    `int` | `getInputSize()`
    `void` | `prepareRead()` Prepare to read from the CSV file.
    `void` | `prepareWrite(int recordCount, int inputSize, int idealSize)` Prepare to write to a CSV file.
    `boolean` | `read(double[] input, double[] ideal, double[] significance)` Read one record of data from a CSV file.
    `void` | `write(double[] input, double[] ideal, double significance)` Write one record of data to a CSV file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CSVDataCODEC

          public CSVDataCODEC(File theFile,
                      CSVFormat theFormat,
                      boolean theExpectSignificance)

      Constructor to create CSV from binary..
      Parameters:
        `theFile` - The CSV file to create.
        `theFormat` - The format for that CSV file.
        `theExpectSignificance` - True, if a significance column is expected.

    - #### CSVDataCODEC

          public CSVDataCODEC(File theFile,
                      CSVFormat theFormat,
                      boolean theHeaders,
                      int theInputCount,
                      int theIdealCount,
                      boolean theExpectSignificance)

      Create a CODEC to load data from CSV to binary.
      Parameters:
        `theFile` - The CSV file to load.
        `theFormat` - The format that the CSV file is in.
        `theHeaders` - True, if there are headers.
        `theInputCount` - The number of input columns.
        `theIdealCount` - The number of ideal columns.
        `theExpectSignificance` - True, if a significance column is expected.

  - ### Method Detail

    - #### close

          public void close()

      Close any open files.
      Specified by:
        `close` in interface `DataSetCODEC`

    - #### getIdealSize

          public int getIdealSize()

      Specified by:
        `getIdealSize` in interface `DataSetCODEC`
      Returns:
        The size of the ideal data.

    - #### getInputSize

          public int getInputSize()

      Specified by:
        `getInputSize` in interface `DataSetCODEC`
      Returns:
        The size of the input data.

    - #### prepareRead

          public void prepareRead()

      Prepare to read from the CSV file.
      Specified by:
        `prepareRead` in interface `DataSetCODEC`

    - #### prepareWrite

          public void prepareWrite(int recordCount,
                          int inputSize,
                          int idealSize)

      Prepare to write to a CSV file.
      Specified by:
        `prepareWrite` in interface `DataSetCODEC`
      Parameters:
        `recordCount` - The total record count, that will be written.
        `inputSize` - The input size.
        `idealSize` - The ideal size.

    - #### read

          public boolean read(double[] input,
                     double[] ideal,
                     double[] significance)

      Read one record of data from a CSV file.
      Specified by:
        `read` in interface `DataSetCODEC`
      Parameters:
        `input` - The input data array.
        `ideal` - The ideal data array.
        `significance` - The significance. The first element will be modified to hold the significance.
      Returns:
        True, if there is more data to be read.

    - #### write

          public void write(double[] input,
                   double[] ideal,
                   double significance)

      Write one record of data to a CSV file.
      Specified by:
        `write` in interface `DataSetCODEC`
      Parameters:
        `input` - The input data array.
        `ideal` - The ideal data array.

Copyright © 2014. All Rights Reserved.