notrockstar
notrockstar

Reputation: 853

Write CSV file into vectors

I have 8x14800 matrix that has been extracted from matlab as CSV file ("moves.mo"). I need to read this file into 14800 vectors with 8 values each. Can you please navigate me here?

So far, I am here:

std::fstream inputfile;
inputfile.open("moves.mo");
std::vector< std::vector<int>* >  vectorsmovesList; 

while (!inputfile.eof()) {
    std::string line;             
    getline (inputfile,line);
    if(""!=line) {        //if line is nonempty

       std::vector<int>* mvec = new std::vector<int>(); //allocate a vector vec(N)
 /* loop to read file has to go here */     
           }
inputfile.close();

}

return 0;
}

Thank you very very much!!!!

Upvotes: 2

Views: 1889

Answers (1)

Foo Bah
Foo Bah

Reputation: 26251

see Split a string in C++?

Upvotes: 2

Related Questions