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 java.lang.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 intREPORT_INTERVALThe default report interval.
-
Constructor Summary
Constructors Constructor and Description BasicFile()Construct the object, and set the defaults.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidappendSeparator(java.lang.StringBuilder line, CSVFormat format)Append a separator.intgetColumnCount()CSVFormatgetFormat()java.io.FilegetInputFilename()java.lang.String[]getInputHeadings()intgetPrecision()intgetRecordCount()StatusReportablegetReport()intgetReportInterval()AnalystScriptgetScript()booleanisAnalyzed()booleanisExpectInputHeaders()booleanisProduceOutputHeaders()voidperformBasicCounts()Perform a basic analyze of the file.java.io.PrintWriterprepareOutputFile(java.io.File outputFile)Prepare the output file, write headers if needed.voidreadHeaders(ReadCSV csv)Read the headers from a CSV file.voidreportDone(boolean isAnalyzing)Report that we are done.voidreportDone(java.lang.String task)Report that we are done.voidrequestStop()Request a stop.voidresetStatus()Reset the reporting stats.voidsetAnalyzed(boolean theAnalyzed)Set to true, if the file has been analyzed.voidsetColumnCount(int theColumnCount)Set the column count.voidsetExpectInputHeaders(boolean theExpectInputHeaders)Set the flag to determine if we are expecting input headers.voidsetInputFilename(java.io.File theInputFilename)Set the input filename.voidsetInputFormat(CSVFormat theInputFormat)Set the input format.voidsetInputHeadings(java.lang.String[] theInputHeadings)Set the input headings.voidsetPrecision(int thePrecision)Set the precision to use.voidsetProduceOutputHeaders(boolean theProduceOutputHeaders)voidsetRecordCount(int v)Set the record count.voidsetReport(StatusReportable theReport)Set the status reporting object.voidsetReportInterval(int theReportInterval)Set the reporting interval.voidsetScript(AnalystScript theScript)booleanshouldStop()java.lang.StringtoString()voidupdateStatus(boolean isAnalyzing)Update the status.voidupdateStatus(java.lang.String task)Report the current status.voidvalidateAnalyzed()Validate that the file has been analyzed.voidwriteRow(java.io.PrintWriter tw, LoadedRow row)Write a row to the output file.
-
-
-
Field Detail
-
REPORT_INTERVAL
public static final int REPORT_INTERVAL
The default report interval.- See Also:
- Constant Field Values
-
-
Method Detail
-
appendSeparator
public static void appendSeparator(java.lang.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 java.io.File getInputFilename()
- Returns:
- The input filename.
-
getFormat
public CSVFormat getFormat()
- Returns:
- THe input format.
-
getInputHeadings
public java.lang.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 java.io.PrintWriter prepareOutputFile(java.io.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(java.lang.String task)
Report that we are done. Used internally.- Parameters:
task- The message.
-
requestStop
public void requestStop()
Request a stop.- Specified by:
requestStopin interfaceQuantTask
-
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(java.io.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(java.lang.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:
shouldStopin interfaceQuantTask- Returns:
- Should we stop?
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.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(java.lang.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(java.io.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
-
-
DMelt 3.0 © DataMelt by jWork.ORG