|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.openforecast.output.DelimitedTextOutputter
public class DelimitedTextOutputter
Defines an Outputter that can be used to write a DataSet in any text
delimited format. For example, space or tab delimited, comma-delimited
(also known as CSV, Comma Separated Values, format). The default delimiter
is the comma, so the resulting output will be in CSV format. This can be
over-ridden using the setDelimiter(java.lang.String)
method. Using the default
delimiter (the comma), this class provides for a quick and easy "export" of
forecast data points to a variety of other applications such as Microsoft
Excel or any other spreadsheet application.
The last value on each row is assumed to represent the dependent variable. For example, if the independent variables are represented by x1, x2, x3 and so on, and the dependent variable is represented by y, then an output row will be of the form:
x1, x2, ..., xi, y
For example, the following output would be produced by the data points (1,3), (2,5), (3,6), and (4,7):
1,3 2,5 3,6 4,7
where the values 3, 5, 6 and 7 are the forecast - or possibly the
observed - values of the dependent variable corresponding to the
associated values of the independent variables with the values 1, 2, 3,
and 4 respectively. The order of the independent variables is determined
by the order of the variables returned by
DataPoint.getIndependentVariableNames()
. By default, a header row
containing these variable names will be output as the first line of output.
To disable this behavior, use setOutputHeaderRow(boolean)
to disable this
option.
Using the previous example, if the x1 represented time, the output would be:
time,dependent value 1,3 2,5 3,6 4,7
Constructor Summary | |
---|---|
DelimitedTextOutputter(File file)
Constructs a new DelimitedTextOutputter that writes its output to the given file. |
|
DelimitedTextOutputter(File file,
boolean append)
Constructs a new DelimitedTextOutputter that writes its output to the given file. |
|
DelimitedTextOutputter(String filename)
Constructs a new DelimitedTextOutputter that writes its output to the named file. |
|
DelimitedTextOutputter(String filename,
boolean append)
Constructs a new DelimitedTextOutputter that writes its output to the named file. |
|
DelimitedTextOutputter(Writer writer)
Constructs a new DelimitedTextOutputter that writes its output to the given Writer object. |
Method Summary | |
---|---|
void |
close()
Close the DelimitedTextOutputter, flushing it first. |
String |
getDelimiter()
Returns the current field delimiter. |
String |
getDependentVariableName()
Returns the current name to be used as the dependent variable name when outputting a header row. |
void |
output(DataPoint dataPoint)
Outputs the given DataPoint to the current Writer. |
void |
output(DataSet dataSet)
Writes a DataSet - a collection of DataPoints - to the current writer. |
void |
setDelimiter(String delimiter)
Sets the field delimiter to the given String. |
void |
setDependentVariableName(String name)
Sets the name/label to be used as the dependent variable name when outputting a header row. |
void |
setOutputHeaderRow(boolean outputHeaderRow)
Enables/Disables the output of the header row containing column/field names. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DelimitedTextOutputter(String filename) throws IOException
filename
- the name of the file to write the data points to.
IOException
- if the specified file is not found or if some other
I/O error occurs.public DelimitedTextOutputter(String filename, boolean append) throws IOException
filename
- the name of the file to write the data points to.append
- if true, then output will be appended to the end of the
file.
IOException
- if the specified file is not found or if some other
I/O error occurs.public DelimitedTextOutputter(File file) throws IOException
file
- the File object specifying the file to write the data points
to.
IOException
- if the specified file is not found or if some other
I/O error occurs.public DelimitedTextOutputter(File file, boolean append) throws IOException
file
- the File object specifying the file to write the data points
to.append
- if true, then output will be appended to the end of the
file.
IOException
- if the specified file is not found or if some other
I/O error occurs.public DelimitedTextOutputter(Writer writer)
writer
- the Writer object to which the data points should be
output.Method Detail |
---|
public String getDelimiter()
setDelimiter(java.lang.String)
method, before invoking output.
public void setDelimiter(String delimiter)
delimiter
- the new delimiter to use to separate fields.public void output(DataSet dataSet) throws IOException
Depending on the setting of outputHeaderRow, a header row containing
the variable names of the data points will be output. To enable/disable
this feature, use the setOutputHeaderRow(boolean)
method.
output
in interface Outputter
dataSet
- the DataSet to be output to the current writer.
IOException
- if an I/O error occurs.public void output(DataPoint dataPoint) throws IOException
dataPoint
- the DataPoint to output to the current Writer.
IOException
- if an I/O error occurs.public void close() throws IOException
IOException
- if an I/O error occurs.public String getDependentVariableName()
setDependentVariableName(java.lang.String)
.
public void setDependentVariableName(String name)
name
- the name/label to be use for the dependent variable name
in any subsequent output.public void setOutputHeaderRow(boolean outputHeaderRow)
output(DataSet)
method is invoked, the first
row/line will contain a comma-separated list of the column names if this
option is enabled before calling the output method.
outputHeaderRow
- set to true if the header row is to be output;
or false to suppress output of the header row.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |