-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (28 loc) · 840 Bytes
/
main.cpp
File metadata and controls
31 lines (28 loc) · 840 Bytes
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
#include "Csv.h"
#include <iostream>
#include <fstream>
int main(int argc, char *argv[]) {
if(argc != 2) {
std::cout << "Incorrect input. CSV-format file should be provided.\n";
return 0;
}
std::string fileName = argv[1];
std::fstream file (fileName, std::ios::in);
if(!file.is_open()) {
std::cout << "Could not open file \"" + fileName + "\".\n";
return 0;
}
csv_interpreter::Csv csvTable;
try {
file >> csvTable;
csvTable.compute();
std::cout << csvTable;
} catch (errors::ErrorInterpreter &e) {
std::cout << e.what() << '\n';
} catch (std::ios_base::failure &) {
std::cout << "Invalid file format\n";
} catch (std::out_of_range &) {
std::cout << "Number entered was out of range.\n";
}
file.close();
}