vincentlaucsb / csv-parser

A high-performance, fully-featured CSV parser and serializer for modern C++.
MIT License
901 stars 150 forks source link

Error with qutoed colums #181

Closed telmo-carmo closed 2 years ago

telmo-carmo commented 3 years ago

Does not handle well this file csv:

um, 123 , "aa;'bb',cc dd" , 1.2345 dois, 456 , "uma ""string"", apenas", 2.5885 tres,,"", , quatro, mais um valor , outro valor "so" , "THE END"

// CL /W3 /std:c++17 /O2 /EHsc /Iinc /D_WIN32 /DWIN32_LEAN_AND_MEAN /D_CRT_SECURE_NO_WARNINGS src\tcsv1.cpp

csv::CSVFormat csv_format;
csv_format.delimiter(',').no_header().trim({ ' ', '\t'  });
csv::CSVReader reader(fname,csv_format);
csv::CSVRow row;

while (reader.read_row(row)) {
    for (csv::CSVField& field: row) {
        std::cout << "[" << field.get<>() << "]; ";
    }
    std::cout << std::endl;
}

--- output: [um]; [123]; ["aa;'bb',cc dd , 1.2345 dois, 456 , "uma "string", apenas]; [2.5885]; [tres]; []; []; []; []; [quatro]; [mais um valor]; [outro valor "so"]; ["THE END];

Thank you for a nice lib

vincentlaucsb commented 2 years ago

There shouldn't be any spaces between a quote used to enclose a field and a delimiter character. It's not RFC 4180 compliant and I don't intend on supporting such files.