从csv文件读取数据到二维vector

void ReadDataFromCsv(std::string &filename, std::vectorstring> > &lines_feat) {
    std::ifstream vm_info(filename.c_str());
    std::string lines, var;
    std::vectorstring> row;

    lines_feat.clear();

    while(!vm_info.eof()) {
        getline(vm_info, lines);
        if(lines.empty())
            break;
        std::istringstream stringin(lines);
        row.clear();

        while(std::getline(stringin, var, ',')) {
            row.push_back(var);
        }
        lines_feat.push_back(row);
    }
}

 

转载于:https://www.cnblogs.com/donggongdechen/p/11039175.html

你可能感兴趣的:(从csv文件读取数据到二维vector)