diff --git a/README.md b/README.md new file mode 100644 index 0000000..357fe07 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# 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](https://gist.github.com/oschonrock/67fc870ba067ebf0f369897a9d52c2dd) . +Function traits taken from [qt-creator](https://code.woboq.org/qt5/qt-creator/src/libs/utils/functiontraits.h.html) . + +Example, lets say we have a csv file containing students in the +following format : + +``` +James Bailey,65,2.5 +Brian S. Wolfe,40,11.9 +Nathan Fielder,37,Really good grades +Bill (Heath) Gates,65,3.3 +``` +``` +#include +#include + +int main() { + ss::parser p{"students.csv", ","}; + if (!p.valid()) { + exit(exit_failure); + } + + while (!p.eof()) { + auto [name, age, grade] = p.get_next(); + + if (p.valid()) { + std::cout << name << ' ' << age << ' ' << grade << std::endl; + } + } + + return 0; +} +``` + +And if we execute the program we get the following output: + +``` +$ ./program +James Bailey 65 2.5 +Brian S. Wolfe 40 11.9 +Bill (Heath) Gates 65 3.3 +``` + +... diff --git a/include/ss/extract.hpp b/include/ss/extract.hpp index 044c7c5..f994430 100644 --- a/include/ss/extract.hpp +++ b/include/ss/extract.hpp @@ -11,10 +11,6 @@ namespace ss { -// todo -// taken from -// https://gist.github.com/oschonrock/67fc870ba067ebf0f369897a9d52c2dd - //////////////// // number converters ////////////////