-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
82 lines (65 loc) · 2.13 KB
/
main.cpp
File metadata and controls
82 lines (65 loc) · 2.13 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include "VGData.h"
#include "matplotlibcpp.h"
#include "MakeGraphs.h"
using namespace std;
namespace plt = matplotlibcpp;
int main() {
vector<VGData> records; // Store the imported data
// Open the CSV file
ifstream inputFile("vgsales.csv");
if (!inputFile.is_open()) {
cout << "Error opening the file!" << endl;
return 1;
}
string line;
while (getline(inputFile, line)) {
stringstream ss(line);
string token;
VGData vgData; // Create a new record for each line in the CSV
getline(ss, vgData.rank, ',');
getline(ss, vgData.name, ',');
getline(ss, vgData.platform, ',');
getline(ss, vgData.year, ',');
getline(ss, vgData.genre, ',');
getline(ss, vgData.publisher, ',');
getline(ss, vgData.naSales, ',');
getline(ss, vgData.euSales, ',');
getline(ss, vgData.jpSales, ',');
getline(ss, vgData.otherSales, ',');
getline(ss, vgData.globalSales, ',');
records.push_back(vgData); // Store the record in the vector
}
inputFile.close();
records.erase(records.begin());
records.erase(records.begin());
cout << "Video Game Data" << endl;
cout << "Choose What You Would Like To See And Press Done To See All" << endl;
int exitLoop = 0;
MakeGraphs graphMaker;
while (exitLoop != 1) {
cout << "1. Genre Bar Chart" << endl;
cout << "2. Publisher Bar Chart" << endl;
cout << "3. Region Sales Scatter Plot" << endl;
cout << "4. Done" << endl;
int userNum = 0;
cin >> userNum;
if (userNum == 1) {
graphMaker.makeGenreBarChart(records);
}
else if (userNum == 2) {
graphMaker.makePublisherBarChart(records);
}
else if (userNum == 3) {
graphMaker.makeSalesScatter(records);
}
else if (userNum == 4) {
exitLoop = 1;
}
}
plt::show(); // When show inside graph function you have to close the current graph for next to load.
return 0;
}