Experiments in reading CSV documents.
Clone the repo and run make
. That will
build and run the tests.
Shrdlu breaks down the problem of parsing CSV data into three stages.
-
A field parser, which parses single fields of a CSV document.
-
Using the Field parser to make a record parser, which parses one CSV record.
-
Using the record parser to make a document parser, which reads an entire CSV document.
Shrdlu is easy to use. Just do extractions from an input stream into one of the parser components, like so:
// Read one field.
Field_parser fp;
input_stream >> fp;
// now do something with fp or with fp.get_field().
// Read one record.
Record_parser rp;
input_sream >> rp;
// do something with rp or with rp.get_record();
// Read one document.
Document_parser dp;
input_stream >> dp;
// do something with dp or with dp.get_document();
Look in test.cc
for details.