-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
33 lines (27 loc) · 833 Bytes
/
test.cpp
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
#include <iostream>
#include "csvparser.hpp"
#include <fstream>
int main()
{
std::ifstream inFile("test_dataset.csv");
CSVReader reader(inFile);
for(auto& row : reader)
{
std::cout <<
row.At("id").ToString() << " " <<
row.At("first_name").ToString() << " " <<
row.At("last_name").ToString() << " " <<
row.At("email").ToString() << " " << std::endl;
}
std::ofstream outFile("output.csv");
CSVWriter writer(outFile, {"name", "email"});
for(auto& row : reader)
{
std::string firstName = row.At("first_name");
std::string lastName = row.At("last_name");
std::string fullName = firstName + " " + lastName;
std::string email = row.At("email");
writer.InsertRow(fullName, email);
}
return 0;
}