Readcsv
Readcsv
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>
#include <TTree.h>
#include <TFile.h>
#include <filesystem>
namespace fs = std::filesystem;
using namespace std;
string line;
int numChannels = 0;
int channelIndex = 0;
while (getline(ss, value, ',')) {
try {
double v = stod(value);
if (isValidValue(v) && channelIndex < numChannels) {
Channels[channelIndex].push_back(v);
}
} catch (...) {
cerr << "⚠️ Warning: Invalid value detected, skipping row." <<
endl;
}
channelIndex++;
}
Time.push_back(t);
}
file.close();
cout << "✅ File " << filename << " successfully processed with " << numChannels
<< " channels!" << endl;
}