-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCSV-TestPrinter.cpp
More file actions
74 lines (66 loc) · 2.06 KB
/
CSV-TestPrinter.cpp
File metadata and controls
74 lines (66 loc) · 2.06 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
/*
This file is used if you would like to test how the csv-extractor
will output data to your file/what is being returned by the extractor
*/
#include <iostream>
#include <vector>
#include <string>
#include "CSV-Extractor.cpp"
int main() {
// Test the CSV-Extractor code snippet
// Create an instance of the csvExtraction class
csvExtraction extractor;
// Call the extractData method to extract data from the CSV file
vector<vector<vector<string>>> data = extractor.extractData();
if (data.empty()) {
std::cout << "No data extracted from the CSV file.\n";
return 1;
}
/*
// Print one item from the extracted data
std::cout << "Title: " << data[0][0][0] << "\n";
std::cout << "Type: " << data[0][1][0] << "\n";
std::cout << "Director: " << data[0][2][0] << "\n";
std::cout << "Actors: ";
bool first = true;
for (const auto& actor : data[0][2]) {
if (first) {
first = false;
continue;
}
std::cout << actor << " ";
}
std::cout << "\n";
std::cout << "Rating: " << data[0][3][0] << "\n";
std::cout << "Duration: " << data[0][4][0] << "\n";
std::cout << "Genre: ";
for (const auto& genre : data[0][5]) {
std::cout << genre << " ";
}
std::cout << "\n\n";
*/
// Print the extracted data
for (const auto& row : data) {
std::cout << "Title: " << row[0][0] << "\n";
std::cout << "Type: " << row[1][0] << "\n";
std::cout << "Director: " << row[2][0] << "\n";
std::cout << "Actors: ";
bool first = true;
for (const auto& actor : row[2]) {
if (first) {
first = false;
continue;
}
std::cout << actor << " ";
}
std::cout << "\n";
std::cout << "Rating: " << row[3][0] << "\n";
std::cout << "Duration: " << row[4][0] << "\n";
std::cout << "Genre: ";
for (const auto& genre : row[5]) {
std::cout << genre << " ";
}
std::cout << "\n\n";
}
return 0;
}