Class FlatFileEx1

All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper

public class FlatFileEx1 extends FlatFile

Reads Fisher's Iris data set from a CSV file.

The Fisher iris data set is frequently used as a sample statistical data set. This example reads the data set in a CSV (comma separated value) format.

The first few lines of the data set are as follows:

 Species,Sepal Length,Sepal Width,Petal Length,Petal Width
 1.0, 5.1, 3.5, 1.4, .2
 1.0, 4.9, 3.0, 1.4, .2
 1.0, 4.7, 3.2, 1.3, .2
 1.0, 4.6, 3.1, 1.5, .2
 1.0, 5.0, 3.6, 1.4, .2
 1.0, 5.4, 3.9, 1.7, .4
 

The first line contains the column names, with a comma as the separator. The rest of the lines contain double data, one observation per line, with comma as a separator.

This example extends the class FlatFile. The FlatFileEx1 constructor constructs a BufferedReader object and calls the FlatFile constructor. It then reads the line containing the column names. The column names are parsed and used to set the column names in FlatFile. All of the columns are also set to type Double.

The class FlatFileEx1 is used in the method main. The data set is assumed to be in a file called "FisherIris.csv" in the same location as the example class file, so that getResourceAsStream can be used to open the file as a stream. Summary statistics are computed for the "Sepal Width" column.

See Also: