geneticWedge.gp.io
Class CSVReader

java.lang.Object
  extended by geneticWedge.gp.io.CSVReader

public class CSVReader
extends java.lang.Object

This class contains static methods for reading csv (comma-separated value) files and returning StringData or NumericData objects.


Constructor Summary
CSVReader()
           
 
Method Summary
static NumericData readFile(java.lang.String filename, boolean labelsInFirstColumn)
          Returns a NumericData object by reading a csv file named filename.
static StringData readStringFile(java.lang.String filename, boolean namesInFirstRow, boolean labelsInFirstColumn)
          Returns a StringData object by reading a csv file named filename.
static void removeDuplicates(java.lang.String filename, java.lang.String newFileName, boolean labelsInFirstColumn)
          Removes duplicated data from the dataset in filename and writes the 'clean' dataset to newFileName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVReader

public CSVReader()
Method Detail

readFile

public static NumericData readFile(java.lang.String filename,
                                   boolean labelsInFirstColumn)
                            throws java.io.FileNotFoundException,
                                   java.io.IOException,
                                   java.lang.NumberFormatException
Returns a NumericData object by reading a csv file named filename. If the first row of the csv file contains variable names, this will be automatically detected by the reader and the variable names may be retrieved from the NumericData object by calling getNames().

Parameters:
filename - A path to the csv file
labelsInFirstColumn - If true, the first column will be treated as String labels rather than data. The labels will be saved and can be retrieved from the NumericData object by calling getLabels()
Throws:
java.io.FileNotFoundException
java.io.IOException
java.lang.NumberFormatException

readStringFile

public static StringData readStringFile(java.lang.String filename,
                                        boolean namesInFirstRow,
                                        boolean labelsInFirstColumn)
                                 throws java.io.FileNotFoundException,
                                        java.io.IOException
Returns a StringData object by reading a csv file named filename.

Parameters:
filename - A path to the csv file
namesInFirstRow - If true, the first column will be treated as variable names rather than data. The names will be saved and can be retrieved from the NumericData object by calling getNames()
labelsInFirstColumn - If true, the first column will be treated as String labels rather than data. The labels will be saved and can be retrieved from the NumericData object by calling getLabels()
Throws:
java.io.FileNotFoundException
java.io.IOException

removeDuplicates

public static void removeDuplicates(java.lang.String filename,
                                    java.lang.String newFileName,
                                    boolean labelsInFirstColumn)
                             throws java.io.IOException
Removes duplicated data from the dataset in filename and writes the 'clean' dataset to newFileName.

Throws:
java.io.IOException