Load a Tab Delimited Text File into into a 2-D Vector of Strings

Hello,

Can someone please provide a snippet to load a tab delimited text file into a 2D vector of strings. Thanks in advance.
assuming there is a set amount of columns in file, say, 10 and no spaces in strings:

1
2
3
4
5
6
7
8
9
10
11
12
13
const std::size_t columns = 10;
std::string word;
std::size_t count = 0;
std::ifstream in("some_file");
std::vector<std::vector<std::string>> data;
std::vector<std::string> row;
while(in >> word) {
    row.push_back(std::move(word));
    if(++count % columns == 0) {
        data.push_back(std::move(row));
        row.clear();
    }
}
Topic archived. No new replies allowed.