Menu

No loadCsv function in the ibrary, contrary to the documentation.

Help
Eren Golge
2015-04-27
2015-04-29
  • Eren Golge

    Eren Golge - 2015-04-27

    In the http://waffles.sourceforge.net/docs/matrices.html , there is a function loadCsv but as far as I see from the code, it is not implemented in the latest version.

     
  • Mike Gashler

    Mike Gashler - 2015-04-28

    I replaced that function with the class GCSVParser. I need to update the docs to reflect this change. Thanks for pointing it out.

    The GCSVParser class provides better error reporting and improved functionality. For example, you can specify date-stamp formats, or the types of ambiguous columns. Here is some example usage:

    GMatrix m;
    GCSVParser p;
    p.parse(m, "somefile.csv");

     
  • Eren Golge

    Eren Golge - 2015-04-28

    Thanks, I realized the class. Additionally, hoe can I define the type of a column

     
  • Anonymous

    Anonymous - 2015-04-29

    If you want to tell it how to interpret the columns in a CSV file, then...
    To specify that column i should be evaluated as continuous, call GCSVParser::setRealAttr(i).
    To specify that column i should be evaluated as categorical, call GCSVParser::setNominalAttr(i).
    Integer types should usually be evaluated as real. Binary types should be evaluated as nominal. For date-stamps, call GCSVParser::setTimeFormat(format), where format is a string such as "YYYY-MM-DD hh:mm:ss".

    If you want to create an uninitialized GMatrix with specified column types, then...
    Here is an example that will create a matrix with 7 rows and 3 columns, where column 0 is binary, column 1 is real, and column 2 has 10 classes:

    vector<size_t> cols;
    cols.push_back(2);
    cols.push_back(0);
    cols.push_back(10);
    GMatrix M(cols);
    M.newRows(7);

     

Anonymous
Anonymous

Add attachments
Cancel