#include <QDateTime>
#include <QString>
#include <QCoreApplication>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
vector<double> ReadXHData(const char *filename)
{
// 获取文件路径
QString Path = QCoreApplication::applicationDirPath();
int first = Path.lastIndexOf("/");
Path = Path.left(first);
QString filePath = Path.append("/data/signal/");
filePath = Path.append(filename);
string lineStr;
ifstream fin;
// 打开文件
fin.open(filePath.toStdString().data());
// 读取一行数据(默认一次信号只有一行数据)
getline(fin, lineStr);
// 按照逗号分开,循环读取数据
stringstream ss(lineStr);
string str;
vector<double> outpArr;
while (getline(ss, str, ',')) {
// 读取的数据,转换成double类型
outpArr.push_back(stod(str));
}
fin.close();
return outpArr;
}
C++解析逗号分割的信号数据
最新推荐文章于 2022-08-26 18:40:55 发布