diff --git a/include/ss/parser.hpp b/include/ss/parser.hpp index 099ea33..fcb1b5a 100644 --- a/include/ss/parser.hpp +++ b/include/ss/parser.hpp @@ -44,7 +44,8 @@ public: if constexpr (ignore_header) { ignore_next(); } else { - header_ = reader_.get_next_row(); + // TODO read header after use_fields is called + header_ = reader_.get_header(); } } else { set_error_file_not_open(); @@ -769,14 +770,15 @@ private: return true; } - std::vector get_next_row() { - std::vector next_row; - next_line_converter_.split(next_line_buffer_, delim_); - auto& next_row_raw = next_line_converter_.splitter_.split_data_; - for (const auto& [begin, end] : next_row_raw) { - next_row.emplace_back(begin, end); + std::vector get_header() { + std::vector header; + std::string header_buffer = next_line_buffer_; + converter_.split(header_buffer.data(), delim_); + auto& header_row_raw = converter_.splitter_.split_data_; + for (const auto& [begin, end] : header_row_raw) { + header.emplace_back(begin, end); } - return next_row; + return header; } //////////////// diff --git a/test/test_parser.cpp b/test/test_parser.cpp index e4069d3..0005dac 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -689,6 +689,7 @@ std::string no_quote(const std::string& s) { } TEST_CASE("parser test csv on multiple lines with quotes") { + // TODO test with "_""_""_",... unique_file_name f; std::vector data = {{1, 2, "\"x\r\nx\nx\""}, {3, 4, "\"y\ny\r\ny\""},