Closed AriaFallah closed 7 years ago
This greatly depends on whether you know the number of fields and their contents (e.g. any string, or just an integer?) at compile time... I'll whack together two small examples to show this.
Done in commit e90e9fd85d1a0756359ad6007e2eb7f9b5cf9350.
I have extended the first example, examples/csv1.cc
, to also build a simple data structure with the parsed data.
Thanks a lot for this! It's very much appreciated.
Good to hear, thanks! I just added actions to examples/csv2.cc
, too, which requires a bit of fiddling around to bridge from run-time-sized std::vector
to compile-time-sized std::tuple
. In real-world code you would probably use a custom class to store a line.
Hey Colin, great library! I'm looking forward to using it. I actually got here through googling
C++ CSV Parser
, which took me here where you wrote:Unfortunately, I didn't see a CSV parser in your
examples
folder, and I was hoping you could add one such that I could see how it'd be done idiomatically with PEGTL.