79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
//
|
|
// Created by Elie Baier on 27.02.24.
|
|
//
|
|
|
|
#include "iostream"
|
|
#include "sstream"
|
|
#include "filesystem"
|
|
#include "fstream"
|
|
|
|
using namespace std;
|
|
|
|
ifstream openDataFile(string path) {
|
|
ifstream file;
|
|
file.open(path);
|
|
if(!file.is_open()) {
|
|
std::cerr << "Error opening file." << std::endl;
|
|
}
|
|
return file;
|
|
}
|
|
|
|
int main() {
|
|
|
|
ofstream out;
|
|
out.open("/Users/eliebaier/Workspace/Physique/TP8/build/extract.csv");
|
|
|
|
out << "Mesure, Diff CH1, Diff CH2" << endl;
|
|
|
|
for(int i = 0; i < 53; i++) {
|
|
|
|
out << i << ",";
|
|
|
|
vector<ifstream> channels;
|
|
if(i < 10) {
|
|
channels.push_back(openDataFile("/Users/eliebaier/Workspace/Physique/TP8/DATA/ALL000" + to_string(i) + "/F000" + to_string(i) + "CH1.CSV"));
|
|
channels.push_back(openDataFile("/Users/eliebaier/Workspace/Physique/TP8/DATA/ALL000" + to_string(i) + "/F000" + to_string(i) + "CH2.CSV"));
|
|
} else {
|
|
channels.push_back(openDataFile("/Users/eliebaier/Workspace/Physique/TP8/DATA/ALL00" + to_string(i) + "/F00" + to_string(i) + "CH1.CSV"));
|
|
channels.push_back(openDataFile("/Users/eliebaier/Workspace/Physique/TP8/DATA/ALL00" + to_string(i) + "/F00" + to_string(i) + "CH2.CSV"));
|
|
}
|
|
|
|
string line;
|
|
for(auto& channel : channels) {
|
|
/* getline(channel, line);
|
|
getline(channel, line);
|
|
|
|
line.erase(0, 16);
|
|
line.erase(12, line.size());
|
|
out << line << ","; */
|
|
|
|
// Skipping the info at the beg
|
|
for(int j = 0; j < 20; j++) {
|
|
getline(channel, line);
|
|
}
|
|
|
|
getline(channel, line);
|
|
line.erase(0, 22);
|
|
line.erase(line.size()-1, line.size());
|
|
|
|
double first = stod(line), second = 0;
|
|
while(second==0) {
|
|
|
|
getline(channel, line);
|
|
line.erase(0, 22);
|
|
line.erase(line.size()-1, line.size());
|
|
double temp = stod(line);
|
|
if(first != temp) {
|
|
second = temp;
|
|
}
|
|
}
|
|
|
|
out << 2*abs(second - first) << ",";
|
|
|
|
}
|
|
|
|
out << endl;
|
|
|
|
}
|
|
}
|