-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadData.cpp
More file actions
70 lines (51 loc) · 1.51 KB
/
ReadData.cpp
File metadata and controls
70 lines (51 loc) · 1.51 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
#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include "BoardGameOBJ/BoardGame.h"
#include "SCHash.cpp"
using namespace std;
void printall(vector<BoardGame> new_test);
int main()
{
// open file
fstream file;
file.open("bgg_dataset.csv");
// line of data
string line = "";
// read in one line of input
getline(file, line);
// variables to store data
string name;
string yearPublished;
string minPlayers;
string maxPlayers;
string minAge;
string avgRating;
// data order from csv file
// ID;Name;Year Published;Min Players;Max Players;Play Time;Min Age;
// while loop until there's no more lines
while(getline(file, line))
{
stringstream input(line);
// name, skip id
getline(input, name, ';');
getline(input, name, ';');
// year published
getline(input, yearPublished, ';');
// min players
getline(input, minPlayers, ';');
// max players
getline(input, maxPlayers, ';');
// min age, skip play time
getline(input, minAge, ';');
getline(input, minAge, ';');
// avg rating, and changes ',' to '.'
getline(input, avgRating, ';');
getline(input, avgRating, ';');
if(avgRating.find(',') != string::npos){
avgRating.replace(avgRating.find(','), 1, ".");
}
BoardGame test = BoardGame(name, yearPublished, minPlayers, maxPlayers, minAge, avgRating);
}
}