|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.openforecast.input.AbstractBuilder net.sourceforge.openforecast.input.CSVBuilder
public class CSVBuilder
Defines a Builder that can be used to construct a DataSet from CSV (Comma Separated Values) file or input stream. This class makes for a quick and easy "import" of data from a variety of other applications such as Microsoft Excel.
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 a row should be of the form:
x1, x2, ..., xi, y
For example, the following represents 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 observed values of the dependent variable corresponding to the associated values of the independent variables with the values 1, 2, 3, and 4 respectively. By default, the independent variables - just one in this example - would be named "x1", ..., "xi", etc. To override this behavior, you can specify a "header row" containing names for the individual variables (the "columns" of data).
Using the previous example, if the xi represented time, we could define the data input as follows:
time, observation 1, 3 2, 5 3, 6 4, 7
This would name the dependent variable in this case, "time", instead of the default, "x1".
Constructor Summary | |
---|---|
CSVBuilder(File file)
Constructs a new CSVBuilder that reads its input from the named file. |
|
CSVBuilder(File file,
boolean hasHeaderRow)
Constructs a new CSVBuilder that reads its input from the named file. |
|
CSVBuilder(FileReader reader)
Constructs a new CSVBuilder that reads its input from the named file input stream. |
|
CSVBuilder(FileReader reader,
boolean hasHeaderRow)
Constructs a new CSVBuilder that reads its input from the named file input stream. |
|
CSVBuilder(String filename)
Constructs a new CSVBuilder that reads its input from the named file. |
|
CSVBuilder(String filename,
boolean hasHeaderRow)
Constructs a new CSVBuilder that reads its input from the named file, and treats the first row of data as a header row containing field names. |
Method Summary | |
---|---|
DataSet |
build()
Retrieves a DataSet - a collection of DataPoints - from the current input source. |
Methods inherited from class net.sourceforge.openforecast.input.AbstractBuilder |
---|
addVariable, getNumberOfVariables, getVariableName, setNumberOfVariables, setVariableName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CSVBuilder(String filename) throws FileNotFoundException
filename
- the name of the CSV file to read the input from.
FileNotFoundException
- if the file does not exist, is a
directory rather than a regular file, or for some other reason cannot
be opened for reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the file.public CSVBuilder(String filename, boolean hasHeaderRow) throws FileNotFoundException
filename
- the name of the CSV file to read the input from.hasHeaderRow
- set to true if the CSV file has a header row.
FileNotFoundException
- if the file does not exist, is a
directory rather than a regular file, or for some other reason cannot
be opened for reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the file.public CSVBuilder(File file) throws FileNotFoundException
file
- the File object specifying the CSV file to read the input
from.
FileNotFoundException
- if the file does not exist, is a
directory rather than a regular file, or for some other reason cannot
be opened for reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the file.public CSVBuilder(File file, boolean hasHeaderRow) throws FileNotFoundException
file
- the File object specifying the CSV file to read the input
from.hasHeaderRow
- set to true if the CSV file has a header row.
FileNotFoundException
- if the file does not exist, is a
directory rather than a regular file, or for some other reason cannot
be opened for reading.
SecurityException
- if a security manager exists and its
checkRead
method denies read access to the file.public CSVBuilder(FileReader reader)
reader
- the FileReader object specifying the CSV file reader to
read the input from.public CSVBuilder(FileReader reader, boolean hasHeaderRow)
reader
- the FileReader object specifying the CSV file reader to
read the input from.hasHeaderRow
- set to true if the CSV file input stream has a
header row.Method Detail |
---|
public DataSet build() throws IOException
In general, build will attempt to convert all lines/rows in the CSV input to data points. The exceptions are as follows:
IOException
- if an error occurred reading from the CSV file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |