Files
handleaiuinew/HanddleAI/HandleAiUi-new/simpleTools/writeCsv.hpp
T
2024-08-14 11:15:16 +08:00

27 lines
587 B
C++

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
void writeCSV(const std::string& filename, const std::vector<std::vector<std::string>>& data) {
std::ofstream file(filename);
if (!file.is_open()) {
std::cerr << "ÎÞ·¨´ò¿ªÎļþ£º" << filename << std::endl;
return;
}
for (const auto& row : data) {
for (size_t i = 0; i < row.size(); ++i) {
file << row[i];
if (i < row.size() - 1) {
file << ",";
}
}
file << "\n";
}
file.close();
}
#pragma once