Simple implementation of CSV file import. Successfully imported items are appended to the model.
This commit is contained in:
29
formats/csvparser.h
Normal file
29
formats/csvparser.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef CSVPARSER_H
|
||||
#define CSVPARSER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace rapidcsv {
|
||||
class Document;
|
||||
}
|
||||
|
||||
class CsvParser {
|
||||
public:
|
||||
static QList<QHash<int, QVariant>> getItemsFromCSVFile(const QString& fileName);
|
||||
|
||||
private:
|
||||
explicit CsvParser();
|
||||
|
||||
static bool isCsvCompatible(const rapidcsv::Document& doc);
|
||||
static QList<QHash<int, QVariant>> createListItemsFromCsvEntries(const rapidcsv::Document& doc);
|
||||
static QHash<QString, std::vector<std::string>> extractColumnValues(
|
||||
const QList<QString> headerNames,
|
||||
const rapidcsv::Document& doc);
|
||||
static QHash<int, QVariant> getItemValuesForRow(
|
||||
const QList<QString>& headerNames,
|
||||
const QHash<QString, std::vector<std::string>>& columnValueMap,
|
||||
const int row);
|
||||
static QVariant parseItemValue(const int role, const std::string& valueString);
|
||||
};
|
||||
|
||||
#endif // CSVPARSER_H
|
||||
Reference in New Issue
Block a user