Documentation of 'net.sourceforge.openforecast.output.DelimitedTextOutputter' Java class
DelimitedTextOutputter
net.sourceforge.openforecast.output

Class DelimitedTextOutputter

  • All Implemented Interfaces:
    Outputter


    public class DelimitedTextOutputter
    extends java.lang.Object
    implements Outputter
    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
     
    Since:
    0.4
    • Constructor Summary

      Constructors 
      Constructor and Description
      DelimitedTextOutputter(java.io.File file)
      Constructs a new DelimitedTextOutputter that writes its output to the given file.
      DelimitedTextOutputter(java.io.File file, boolean append)
      Constructs a new DelimitedTextOutputter that writes its output to the given file.
      DelimitedTextOutputter(java.lang.String filename)
      Constructs a new DelimitedTextOutputter that writes its output to the named file.
      DelimitedTextOutputter(java.lang.String filename, boolean append)
      Constructs a new DelimitedTextOutputter that writes its output to the named file.
      DelimitedTextOutputter(java.io.Writer writer)
      Constructs a new DelimitedTextOutputter that writes its output to the given Writer object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Close the DelimitedTextOutputter, flushing it first.
      java.lang.String getDelimiter()
      Returns the current field delimiter.
      java.lang.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(java.lang.String delimiter)
      Sets the field delimiter to the given String.
      void setDependentVariableName(java.lang.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

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DelimitedTextOutputter

        public DelimitedTextOutputter(java.lang.String filename)
                               throws java.io.IOException
        Constructs a new DelimitedTextOutputter that writes its output to the named file.
        Parameters:
        filename - the name of the file to write the data points to.
        Throws:
        java.io.IOException - if the specified file is not found or if some other I/O error occurs.
      • DelimitedTextOutputter

        public DelimitedTextOutputter(java.lang.String filename,
                                      boolean append)
                               throws java.io.IOException
        Constructs a new DelimitedTextOutputter that writes its output to the named file. If the second argument is true, then output will be appended to the end of the file rather over-writing the file.
        Parameters:
        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.
        Throws:
        java.io.IOException - if the specified file is not found or if some other I/O error occurs.
      • DelimitedTextOutputter

        public DelimitedTextOutputter(java.io.File file)
                               throws java.io.IOException
        Constructs a new DelimitedTextOutputter that writes its output to the given file.
        Parameters:
        file - the File object specifying the file to write the data points to.
        Throws:
        java.io.IOException - if the specified file is not found or if some other I/O error occurs.
      • DelimitedTextOutputter

        public DelimitedTextOutputter(java.io.File file,
                                      boolean append)
                               throws java.io.IOException
        Constructs a new DelimitedTextOutputter that writes its output to the given file. If the second argument is true, then output will be appended to the end of the file rather over-writing the file.
        Parameters:
        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.
        Throws:
        java.io.IOException - if the specified file is not found or if some other I/O error occurs.
      • DelimitedTextOutputter

        public DelimitedTextOutputter(java.io.Writer writer)
        Constructs a new DelimitedTextOutputter that writes its output to the given Writer object.
        Parameters:
        writer - the Writer object to which the data points should be output.
    • Method Detail

      • getDelimiter

        public java.lang.String getDelimiter()
        Returns the current field delimiter. By default, this is set to be a comma. The value used can be overridden using the setDelimiter(java.lang.String) method, before invoking output.
        Returns:
        the current delimiter that will be used to separate fields.
      • setDelimiter

        public void setDelimiter(java.lang.String delimiter)
        Sets the field delimiter to the given String.
        Parameters:
        delimiter - the new delimiter to use to separate fields.
      • output

        public void output(DataSet dataSet)
                    throws java.io.IOException
        Writes a DataSet - a collection of DataPoints - to the current writer. The DataSet should contain all DataPoints to be output.

        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.

Specified by:
output in interface Outputter
Parameters:
dataSet - the DataSet to be output to the current writer.
Throws:
java.io.IOException - if an I/O error occurs.
Skip navigation links

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.