org.encog.app.analyst.csv.basic

## Class BasicFile

- java.lang.Object
- - org.encog.app.analyst.csv.basic.BasicFile

- All Implemented Interfaces:
    QuantTask
  Direct Known Subclasses:
    AnalystClusterCSV, AnalystEvaluateCSV, AnalystEvaluateRawCSV, AnalystNormalizeCSV, AnalystNormalizeToEGB, AnalystProcess, BalanceCSV, BasicCachedFile, FilterCSV, SegregateCSV, ShuffleCSV, SortCSV

      public class BasicFile
      extends Object
      implements QuantTask

  Many of the Encog quant CSV processors are based upon this class. This class is not useful on its own. However, it does form the foundation for most Encog CSV file processing.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `REPORT_INTERVAL` The default report interval.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicFile()` Construct the object, and set the defaults.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `appendSeparator(StringBuilder line, CSVFormat format)` Append a separator.
    `int` | `getColumnCount()`
    `CSVFormat` | `getFormat()`
    `File` | `getInputFilename()`
    `String[]` | `getInputHeadings()`
    `int` | `getPrecision()`
    `int` | `getRecordCount()`
    `StatusReportable` | `getReport()`
    `int` | `getReportInterval()`
    `AnalystScript` | `getScript()`
    `boolean` | `isAnalyzed()`
    `boolean` | `isExpectInputHeaders()`
    `boolean` | `isProduceOutputHeaders()`
    `void` | `performBasicCounts()` Perform a basic analyze of the file.
    `PrintWriter` | `prepareOutputFile(File outputFile)` Prepare the output file, write headers if needed.
    `void` | `readHeaders(ReadCSV csv)` Read the headers from a CSV file.
    `void` | `reportDone(boolean isAnalyzing)` Report that we are done.
    `void` | `reportDone(String task)` Report that we are done.
    `void` | `requestStop()` Request a stop.
    `void` | `resetStatus()` Reset the reporting stats.
    `void` | `setAnalyzed(boolean theAnalyzed)` Set to true, if the file has been analyzed.
    `void` | `setColumnCount(int theColumnCount)` Set the column count.
    `void` | `setExpectInputHeaders(boolean theExpectInputHeaders)` Set the flag to determine if we are expecting input headers.
    `void` | `setInputFilename(File theInputFilename)` Set the input filename.
    `void` | `setInputFormat(CSVFormat theInputFormat)` Set the input format.
    `void` | `setInputHeadings(String[] theInputHeadings)` Set the input headings.
    `void` | `setPrecision(int thePrecision)` Set the precision to use.
    `void` | `setProduceOutputHeaders(boolean theProduceOutputHeaders)`
    `void` | `setRecordCount(int v)` Set the record count.
    `void` | `setReport(StatusReportable theReport)` Set the status reporting object.
    `void` | `setReportInterval(int theReportInterval)` Set the reporting interval.
    `void` | `setScript(AnalystScript theScript)`
    `boolean` | `shouldStop()`
    `String` | `toString()`
    `void` | `updateStatus(boolean isAnalyzing)` Update the status.
    `void` | `updateStatus(String task)` Report the current status.
    `void` | `validateAnalyzed()` Validate that the file has been analyzed.
    `void` | `writeRow(PrintWriter tw, LoadedRow row)` Write a row to the output file.

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

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

- - ### Field Detail

    - #### REPORT_INTERVAL

          public static final int REPORT_INTERVAL

      The default report interval.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BasicFile

          public BasicFile()

      Construct the object, and set the defaults.

  - ### Method Detail

    - #### appendSeparator

          public static void appendSeparator(StringBuilder line,
                             CSVFormat format)

      Append a separator. The separator will only be appended if the line is not empty. This is used to build comma(or other) separated lists.
      Parameters:
        `line` - The line to append to.
        `format` - The format to use.

    - #### getColumnCount

          public int getColumnCount()

      Returns:
        The column count.

    - #### getInputFilename

          public File getInputFilename()

      Returns:
        The input filename.

    - #### getFormat

          public CSVFormat getFormat()

      Returns:
        THe input format.

    - #### getInputHeadings

          public String[] getInputHeadings()

      Returns:
        The input headings.

    - #### getPrecision

          public int getPrecision()

      Returns:
        The precision to use.

    - #### getRecordCount

          public int getRecordCount()

      Returns:
        Get the record count. File must have been analyzed first to read the record count.

    - #### getReport

          public StatusReportable getReport()

      Returns:
        The status reporting object.

    - #### getReportInterval

          public int getReportInterval()

      Returns:
        The reporting interval, an update will be sent for every block of rows that matches the size of this property.

    - #### isAnalyzed

          public boolean isAnalyzed()

      Returns:
        Has the file been analyzed.

    - #### isExpectInputHeaders

          public boolean isExpectInputHeaders()

      Returns:
        True if we are expecting input headers.

    - #### isProduceOutputHeaders

          public boolean isProduceOutputHeaders()

      Returns:
        the produceOutputHeaders

    - #### performBasicCounts

          public void performBasicCounts()

      Perform a basic analyze of the file. This method is used mostly internally.

    - #### prepareOutputFile

          public PrintWriter prepareOutputFile(File outputFile)

      Prepare the output file, write headers if needed.
      Parameters:
        `outputFile` - The name of the output file.
      Returns:
        The output stream for the text file.

    - #### readHeaders

          public void readHeaders(ReadCSV csv)

      Read the headers from a CSV file. Used mostly internally.
      Parameters:
        `csv` - The CSV file to read from.

    - #### reportDone

          public void reportDone(boolean isAnalyzing)

      Report that we are done. Used internally.
      Parameters:
        `isAnalyzing` - True if we are analyzing.

    - #### reportDone

          public void reportDone(String task)

      Report that we are done. Used internally.
      Parameters:
        `task` - The message.

    - #### requestStop

          public void requestStop()

      Request a stop.
      Specified by:
        `requestStop` in interface `QuantTask`

    - #### resetStatus

          public void resetStatus()

      Reset the reporting stats. Used internally.

    - #### setAnalyzed

          public void setAnalyzed(boolean theAnalyzed)

      Set to true, if the file has been analyzed.
      Parameters:
        `theAnalyzed` - True, if the file has been analyzed.

    - #### setColumnCount

          public void setColumnCount(int theColumnCount)

      Set the column count.
      Parameters:
        `theColumnCount` - The new column count.

    - #### setExpectInputHeaders

          public void setExpectInputHeaders(boolean theExpectInputHeaders)

      Set the flag to determine if we are expecting input headers.
      Parameters:
        `theExpectInputHeaders` - Are input headers expected?

    - #### setInputFilename

          public void setInputFilename(File theInputFilename)

      Set the input filename.
      Parameters:
        `theInputFilename` - The input filename.

    - #### setInputFormat

          public void setInputFormat(CSVFormat theInputFormat)

      Set the input format.
      Parameters:
        `theInputFormat` - The new inputFormat format.

    - #### setInputHeadings

          public void setInputHeadings(String[] theInputHeadings)

      Set the input headings.
      Parameters:
        `theInputHeadings` - The new input headings.

    - #### setPrecision

          public void setPrecision(int thePrecision)

      Set the precision to use.
      Parameters:
        `thePrecision` - The precision to use.

    - #### setProduceOutputHeaders

          public void setProduceOutputHeaders(boolean theProduceOutputHeaders)

      Parameters:
        `theProduceOutputHeaders` - the produceOutputHeaders to set

    - #### setRecordCount

          public void setRecordCount(int v)

      Set the record count.
      Parameters:
        `v` - The record count.

    - #### setReport

          public void setReport(StatusReportable theReport)

      Set the status reporting object.
      Parameters:
        `theReport` - The status reporting object.

    - #### setReportInterval

          public void setReportInterval(int theReportInterval)

      Set the reporting interval.
      Parameters:
        `theReportInterval` - The new reporting interval.

    - #### shouldStop

          public boolean shouldStop()

      Specified by:
        `shouldStop` in interface `QuantTask`
      Returns:
        Should we stop?

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### updateStatus

          public void updateStatus(boolean isAnalyzing)

      Update the status. Used internally.
      Parameters:
        `isAnalyzing` - True if we are in the process of analyzing.

    - #### updateStatus

          public void updateStatus(String task)

      Report the current status.
      Parameters:
        `task` - The string to report.

    - #### validateAnalyzed

          public void validateAnalyzed()

      Validate that the file has been analyzed. Throw an error, if it has not.

    - #### writeRow

          public void writeRow(PrintWriter tw,
                      LoadedRow row)

      Write a row to the output file.
      Parameters:
        `tw` - The output stream.
        `row` - The row to write out.

    - #### getScript

          public AnalystScript getScript()

      Returns:
        the script

    - #### setScript

          public void setScript(AnalystScript theScript)

      Parameters:
        `theScript` - the script to set

Copyright © 2014. All Rights Reserved.