Aggiunta RELEASES da v0.1 a v1.1

This commit is contained in:
2026-06-24 10:02:13 +02:00
parent f4dd508152
commit 9bd44d7c5f
496 changed files with 1406460 additions and 1 deletions
@@ -0,0 +1,27 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#ifndef CSV_H
#define CSV_H
#define DATA_PATH std::string("./../../data/")
class CSVProcessor {
private:
std::vector<std::string> headers;
std::vector<std::vector<float>> data;
public:
// Method to read CSV file and store data in vectors
void readCSVFile(const std::string& filename);
// Getter for headers
const std::vector<std::string>& getHeaders() const;
// Getter for data
const std::vector<std::vector<float>>& getData() const;
};
#endif
@@ -0,0 +1,53 @@
#include "../headers/csv.hpp"
void CSVProcessor::readCSVFile(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
throw std::runtime_error("Could not open file: " + filename);
}
std::string line;
// Read headers (first line)
if (std::getline(file, line)) {
std::stringstream ss(line);
std::string header;
while (std::getline(ss, header, ',')) {
headers.push_back(header);
}
}
data.clear();
// Read data
while (std::getline(file, line)) {
std::vector<float> row;
std::stringstream ss(line);
std::string value;
while (std::getline(ss, value, ',')) {
try {
row.push_back(std::stof(value));
} catch (const std::invalid_argument& e) {
// Handle non-integer values if needed
row.push_back(0); // or some other default/error value
}
}
data.push_back(row);
}
file.close();
}
// Getter for headers
const std::vector<std::string>& CSVProcessor::getHeaders() const {
return headers;
}
// Getter for data
const std::vector<std::vector<float>>& CSVProcessor::getData() const {
return data;
}