c++ - 从文件读取时将对象添加到向量中
问题描述
将由 , 分隔的 csv 文件添加到蛋白质对象时遇到问题。任何帮助将不胜感激。
vector<Protein> proteins;
Protein prot;
// load disprot database of intrinsically disordered proteins
std::ifstream reading;
reading.open("C:\\Users\\james\\CLionProjects\\untitled1\\disprot.csv");
std::string line, col;
if (reading.is_open()){
while (reading.good()){
std::getline(reading, line);
std::stringstream ss(line);
while(std::getline(ss, col, ',')){
Protein temp(ss.get(), ss.get(),ss.get(),col.get_allocator())
proteins.push_back(prot);
}
}
reading.close();
}
else if(!reading.is_open()) throw std::runtime_error("Could not open file");
解决方案
推荐阅读
- python - 熊猫按时间顺序重复行
- amazon-web-services - RethinkDB 与 i3.Metal 实例上的 1.5k 写入作斗争
- c++ - QWidget move() 和 QGraphicsOpacityEffect 导致黑色边框
- angular - 以嵌套反应形式使用 setControl
- python - 创建一个适用于具有相似功能的多个按钮的功能
- pandas - 按数据框中的两列分组,然后显示另外两列的平均值
- c# - 将图像添加到资源后,WinForm c#未编译
- xamarin.forms - 来自 http 的图像不会在 Xamarin iOS 项目中加载
- javascript - 使用带有 d3.drag () 的 keydown 事件来旋转 SVG
- swift - MKCoordinateRegionMakeWithDistance 在 iphoneX 上给出错误的结果