openGPMP
Open Source Mathematics Package
tables.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <chrono>
3 #include <fstream>
4 #include <iostream>
6 #include <regex>
7 #include <sstream>
8 #include <string>
9 #include <typeinfo>
10 #include <vector>
11 
12 int main() {
13  /*
14  * for now specific columns must be in the order they appear in the file
15  * being read in
16  */
17  std::chrono::steady_clock::time_point start_time =
18  std::chrono::steady_clock::now();
20 
21  // DataTableStr is of type std::pair<std::vector<std::string>,
22  gpmp::core::DataTableStr result = dt.csv_read("../../data/1m.csv");
23 
24  // display() takes a DataTableStr or default to displaying the current obj
25  dt.display(result);
26 
27  // time the time taken to perform the DataTable methods
28  std::chrono::steady_clock::time_point end_time =
29  std::chrono::steady_clock::now();
30 
31  std::cout << "\nTime elapsed: "
32  << std::chrono::duration_cast<std::chrono::milliseconds>(
33  end_time - start_time)
34  .count()
35  << " ms" << std::endl;
36 
37  return 0;
38 }
DataTableStr csv_read(std::string filename, std::vector< std::string > columns={})
Reads a CSV file and returns a DataTableStr parses CSV files and stores all data as strings.
Definition: datatable.cpp:57
void display(std::pair< std::vector< T >, std::vector< std::vector< T >>> data, bool display_all=false)
Sort a DataTable based on a specified column.
Definition: datatable.hpp:216
std::pair< std::vector< std::string >, std::vector< std::vector< std::string > > > DataTableStr
Definition: datatable.hpp:65
int main()
Definition: tables.cpp:12