NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
csvmanager.h
Go to the documentation of this file.
1#ifndef CSVMANAGER_H
2#define CSVMANAGER_H
3
4#include <QObject>
5#include <QString>
6#include <QVector>
7
8class CSVManager : public QObject {
9 Q_OBJECT
10public:
22 explicit CSVManager(QObject* parent = nullptr);
23
32 QVector<QVector<QString>> readCSV(const QString& filename, const QString& delimiter, bool firstRowHeader = true);
33
41 QVector<QVector<QString>> filterByColumn(int column, const QString& value) const;
42
51 QVector<QVector<QString>> filterByColumn(const QVector<QVector<QString>>& data, int column, const QString& value) const;
52
59 QStringList getDistinctColumnValues(int column) const;
60
68 QVector<QString> getColumnValues(const QVector<QVector<QString>>& data, int column) const;
69
70signals:
76 void dataReady(const QVector<QVector<QString>>& data);
77
78private:
79 QVector<QVector<QString>> data;
80};
81
82#endif // CSVMANAGER_H
Definition csvmanager.h:8
QVector< QVector< QString > > filterByColumn(int column, const QString &value) const
Filters the data based on a specific column and value.
Definition csvmanager.cpp:40
QVector< QString > getColumnValues(const QVector< QVector< QString > > &data, int column) const
Retrieves the values in a specific column from the provided data.
Definition csvmanager.cpp:89
void dataReady(const QVector< QVector< QString > > &data)
Signal emitted when the data is ready.
QVector< QVector< QString > > readCSV(const QString &filename, const QString &delimiter, bool firstRowHeader=true)
Reads a CSV file and returns the data as a 2D QVector of QString values.
Definition csvmanager.cpp:12
QStringList getDistinctColumnValues(int column) const
Retrieves the distinct values in a specific column.
Definition csvmanager.cpp:71