System 1: ThinkPad T570, Windows10, QT5.12.2 (Qt Creater 4.8.2)
wrote a QT by the data written csv file and save it to a local function, procedure is as follows:
QVector<float> vCSVdata;
vCSVdata.push_back(1.1f);
vCSVdata.push_back(1.2f);
vCSVdata.push_back(1.3f);
vCSVdata.push_back(1.4f);
QString wstrFilePath;
wstrFilePath = qApp->applicationDirPath() + "/test.csv" ;
//qApp->applicationDirPath()获取到当前.exe执行程序所在路径
QString FILE_PATH(wstrFilePath);
QFile csvFile(FILE_PATH);
QStringList CSVList;
CSVList.clear();
if (csvFile.open(QIODevice::ReadWrite))
{
QTextStream stream(&csvFile);
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
stream<<vCSVdata.at(2*i+j)<<",";
}
stream<<"\n";
}
}
csvFile.close();
After running the program, the file appears test.csv execution paths, with open excel can see the data file as shown below:
About the code reading csv data seen my other blog post:
https://blog.csdn.net/weixin_43935474/article/details/89003348