ben-strasser / fast-cpp-csv-parser

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

Compile time error in README example for allowing optional columns #111

Closed axlan closed 3 years ago

axlan commented 3 years ago

The README gives the following example for how to use a mix of required and optional columns:

#include "csv.h"

int main() {
    // The file only contains the columns "a" and "b"
    io::CSVReader<2>in("test.csv");
    in.read_header(io::ignore_missing_column, "a", "b", "sum");
    if (!in.has_column("a") || !in.has_column("b")) {
        throw io::error::missing_column_in_header();
    }
    bool has_sum = in.has_column("sum");
    int a, b, sum;
    while (in.read_row(a, b, sum)) {
        if (!has_sum)
            sum = a + b;
    }
}

This gives a static error too many columns specified. It appears it's a typo and template column count should be 3.

ben-strasser commented 3 years ago

thanks for the report, it is fixed :)