2020-12-12 03:28:40 +08:00
|
|
|
#ifndef CSV_H
|
|
|
|
#define CSV_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class CSV
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CSV();
|
|
|
|
|
|
|
|
static CSV fromFile(QString filename, char sep = ',');
|
|
|
|
|
|
|
|
void toFile(QString filename, char sep = ',');
|
|
|
|
std::vector<double> getColumn(QString header);
|
|
|
|
std::vector<double> getColumn(unsigned int index);
|
2020-12-13 05:51:38 +08:00
|
|
|
QString getHeader(unsigned int index);
|
2020-12-12 03:28:40 +08:00
|
|
|
unsigned int columns() { return _columns.size();}
|
|
|
|
|
|
|
|
void addColumn(QString name, const std::vector<double> &data);
|
|
|
|
|
2020-12-13 05:51:38 +08:00
|
|
|
QString getFilename() const;
|
|
|
|
void setFilename(const QString &value);
|
|
|
|
|
2020-12-12 03:28:40 +08:00
|
|
|
private:
|
|
|
|
class Column {
|
|
|
|
public:
|
|
|
|
QString header;
|
|
|
|
std::vector<double> data;
|
|
|
|
};
|
|
|
|
std::vector<Column> _columns;
|
2020-12-13 05:51:38 +08:00
|
|
|
QString filename;
|
2020-12-12 03:28:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CSV_H
|