ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.15k stars 440 forks source link

Variable number of columns per line #15

Closed pgp78 closed 8 years ago

pgp78 commented 8 years ago

Can this class be used to parse a single CSV file without a header that may contain a variable number of columns per line?

For example, each line's first column may contain a type. Some types may be associated with more or less columns than others.

The goal would be to have a way of iterating through each line, peeking at the type in the first column, and parsing other fields as needed based on the type.

ben-strasser commented 8 years ago

On Thu, 14 Jan 2016 14:38:44 -0800 pgp78 notifications@github.com wrote:

Can this class be used to parse a single CSV file without a header that may contain a variable number of columns per line?

No, a variable number of columns per line is regarded as invalid CSV file. There is no way to easily change that.

You could recycle the LineReader class and separate the string at the ',' manually though. With this approach you still get the asynchronous reading. This should give you a pretty efficient way of getting a string-array/vector of the elements in a row.