-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSVFile.h
40 lines (37 loc) · 1.11 KB
/
CSVFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <string>
#include <vector>
#include <map>
class CSVFile
{
public:
//îòêðûòèå ôàéëà
bool open(std::string FileName, std::string delim = ";");
//ñêîëüêî âñåãî ñòðî÷åê
size_t getSizeRow();
//÷èñëî ñòîëáöîâ
size_t getSizeColumn();
//íîìåð íîìåð ñòîëáöà ïî íàçâàíèþ
size_t getColumnNumByName(std::string columnName);
//âåðíóòü ÿ÷åéêó ïî ïîçèöèè
std::string getColumnValueByNum(size_t rowNum, size_t columnNum);
//âåðíóòü ÿ÷åéêó ïî íàçâàíèþ ñòîëöà
std::string getColumnValueByName(size_t rowNum, std::string columnName);
//âåðíóòü ñòîëáåö ïî íîìåðó
std::vector<std::string> getColumnByNum(std::size_t columnNum);
//âåðíóòü ñòîëáåö ïî íàçâàíèþ
std::vector<std::string> getColumnByName(std::string columnName);
private:
//÷èñëî ñòðîê
size_t sizeRow_;
//÷èñëî ñòîëáöîâ
size_t sizeColumn_;
//ðàçäåëèòåëü
std::string delimiter = ";";
//íàçâàíèå êîëîíêè, ÷òîáû áûñòðî âûòàùèòü èäåíòèôèêàòîð
std::multimap<std::string, size_t> columnName;
//ñîäåðæàíèå ôàéëà
//ïåðâîå ñòðîêà , âòîðîå ñòîëáåö
std::vector<std::vector<std::string>> dataFile;
std::vector<std::string> readNextRow(std::ifstream& str);
};