-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (21 loc) · 1016 Bytes
/
main.cpp
File metadata and controls
30 lines (21 loc) · 1016 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
#include <iostream>
#include <chrono>
#include "lib/fastCSV/fastCSV.hpp"
#include "lib/fastCSV/rawReadBuffer.hpp"
#include "lib/fastCSV/gzipReadBuffer.hpp"
int main() {
auto fastCSV = new FastCSV<500, GzipReadBuffer>("../data.csv.gz");
auto start = std::chrono::steady_clock::now();
fastCSV->nextRow(); // skips header
const auto &second_row = fastCSV->getRow(); // gets current row (2nd)
std::string_view first_col = second_row[-2]; // access second to last column of row
std::string_view second_row_string = second_row.getRaw(); // get the whole row as a string
std::cerr << first_col << "\n" << second_row_string << "\n";
for (const auto &row : *fastCSV) {
if (row[2] == "ColumnText") // std::string_view supports == between strings
std::cerr << row.getRaw();
}
auto end = std::chrono::steady_clock::now();
printf("total: %f ms\n", (double) std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() / 1e+6);
return 0;
}