Closed telmo-carmo closed 2 years ago
// 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; }
Thank you for a nice lib
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.
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
--- 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