2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
6 #include "CsvReader.hpp"
8 #include <boost/algorithm/string.hpp>
9 #include <boost/tokenizer.hpp>
15 using Tokenizer = boost::tokenizer<boost::escaped_list_separator<char>>;
20 CsvRow ParseLine(const std::string& csvLine)
22 Tokenizer tokenizer(csvLine);
25 for (const auto &token : tokenizer)
27 entry.values.push_back(boost::trim_copy(token));
32 std::vector<CsvRow> CsvReader::ParseFile(const std::string& csvFile)
34 std::vector<CsvRow> result;
36 std::ifstream in(csvFile.c_str());
41 while (getline(in, line))
45 CsvRow entry = ParseLine(line);
46 result.push_back(entry);
52 std::vector<CsvRow> CsvReader::ParseVector(const std::vector<std::string>& csvVector)
54 std::vector<CsvRow> result;
56 for (auto const& line: csvVector)
58 CsvRow entry = ParseLine(line);
59 result.push_back(entry);
63 } // namespace armnnUtils