C++ CSV parser
Go to file
2020-12-27 20:54:47 +01:00
include/ss add README, start writing documentation 2020-12-27 20:50:45 +01:00
test make default error_mode Bool 2020-12-27 17:00:06 +01:00
.gitignore initial commit, copy everything to new repository 2020-12-10 19:26:56 +01:00
LICENSE Initial commit 2020-12-10 18:59:46 +01:00
makefile update converter.hpp to work with gcc, add uninstall to makefile 2020-12-10 20:41:49 +01:00
README.md add cpp higlight 2020-12-27 20:54:47 +01:00

Static split parser

A header only "csv" parser which is fast and versatile with modern c++ api. Requires compiler with c++17 support.

Conversion for numeric values taken from oliver schönrock .
Function traits taken from qt-creator .

Example, lets say we have a csv file containing students in the following format <name,age,grade>:

$ cat students.csv
James Bailey,65,2.5
Brian S. Wolfe,40,11.9
Nathan Fielder,37,Really good grades
Bill (Heath) Gates,65,3.3
#include <iostream>
#include <ss/parser.hpp>

int main() {
    ss::parser p{"students.csv", ","};
    if (!p.valid()) {
        exit(exit_failure);
    }

    while (!p.eof()) {
        auto [name, age, grade] = p.get_next<std::string, int, double>();

        if (p.valid()) {
            std::cout << name << ' ' << age << ' ' << grade << std::endl;
        }
    }

    return 0;
}

And if we compile and execute the program we get the following output:

$ ./a.out
James Bailey 65 2.5
Brian S. Wolfe 40 11.9
Bill (Heath) Gates 65 3.3

...