27 Jul
2009
27 Jul
'09
6:18 p.m.
On Mon, Jul 27, 2009 at 6:52 AM, Sean
Farrow
Hi:
I am currently using the boost.spirit example to process a csv file. Rather than stuffing all values in to a vector as the example does what I’dx like to do is to determine how many columns exist and stuff all values in to a multi-dimensional array.
What is the best way of doing this?
Look up boost::tokenizer and escaped_list_separator. This was built exactly to handle the CSV file format (technically, a superset of csv). use std::distance to find out how many tokens (columns) were found (e.g. if you need to pre-allocate your array based on the number of columns), and then iterate through them using standard methods to insert each one.