Probelms loading csv files as ofFile from ofDirectory

hello,

i am attempting to load a list of csv files from a folder using ofDirectory:

in my .h file:

ofFile dataFile[11];

in my .cpp file:

    string data_path = "path to data";
    ofDirectory data_dir;
    data_dir.listDir(data_path);
    data_dir.allowExt("csv");
    data_dir.sort();

    int dataCnt = 0;
    for(int i = 0; i < (int)data_dir.size(); i ++) {
        ofLog(OF_LOG_NOTICE, data_dir.getPath(i));
        dataFile[dataCnt](ofToDataPath(data_dir.getPath(i)));
        dataCnt ++;
    }

this seems like it should be straightforward, since the data_dir.getPath() is a path, but the error i receive is: Type ‘ofFile’ does not provide a call operator. i don’t understand why. i’ve tried other iterations with the same error flag raised:

dataFile[dataCnt](data_dir.getPath(i));

dataFile[dataCnt](ofToDataPath(ofFilePath(data_dir.getPath(i))));

dataFile[dataCnt](ofFilePath(data_dir.getPath(i)));

is it not possible batch-load ofFile objects this way?

thanks in advance.

01

Hey @robotPatrol,

Refering to https://openframeworks.cc/documentation/utils/ofFile/, you can see there is effectively no callable overload operator ( “operator()” ). I believe you want to call :

dataFile[dataCnt].open(data_dir.getPath(i));

instead.

Cheers.

thanks for directing me to that page and using the documentation headers as links as well. the page i landed on was ofFile::ofFile, which is not as detailed.

cheers,
01