9#ifndef DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_FILES_FILEPARSING_PARSERSTRATEGIES_COLUMNSTRATEGY_HPP
10#define DRYCHEM_COMMON_UTILITIES_INCLUDE_COMMON_UTILS_FILES_FILEPARSING_PARSERSTRATEGIES_COLUMNSTRATEGY_HPP
30 if (tokenIndex_ == columnIndex_)
40 [](
const std::string& column) { return column.substr(0, column.size() - 1); });
54 const std::string& fileContents_,
const std::optional<std::string>& fieldSeparator_ = std::nullopt)
const
58 std::string delimiters = fieldSeparator_.value_or(
"") +
" \t\n";
62 auto tokens = tok.
split();
65 for (std::size_t i {}, j {}; i < tokens.size(); ++i)
67 if (tokens[i] ==
"\n")
73 columnCache[j++].append(tokens[i]).append(fieldSeparator_.value_or(
"\t"));
Definition columnStrategy.hpp:23
std::vector< std::string > columnCache
Definition columnStrategy.hpp:25
void trimTrainingSeparators() const
Definition columnStrategy.hpp:36
void resetColumnsOnNewLine(std::size_t tokenIndex_, std::size_t &columnIndex_) const
Definition columnStrategy.hpp:27
auto operator()(const std::string &fileContents_, const std::optional< std::string > &fieldSeparator_=std::nullopt) const
Definition columnStrategy.hpp:53
Definition tokenizer.hpp:62
constexpr Container split()
Definition tokenizer.hpp:148
Definition fileParser.hpp:23