Hi,
I have a tab separated value table like this:
header1 header2 header3
13.455 55.3 A string
4.55 5.66 Another string
I want to load this guy into a vector of vectors, since I do not know how
long it may be. I think I have to have a vector of vectors of strings, and
then extract the doubles later(?):
std::vector<std ::vector<std::s tring> > m_data_vec;
I started off with this skeletal function, but Im not sure how to parse the
line for tabs and newlines, and stuff the elements into the vector. Is it
better to read in the whole line then parse it? Can I parse it on the fly?
How?
void MyClass::ReadTS V(const* filename)
{
using namespace std;
ifstream infile(filename );
if (!infile) {
cout << "unable to load file" << endl;
}
// Now what?
}
Thanks,
Bryan
I have a tab separated value table like this:
header1 header2 header3
13.455 55.3 A string
4.55 5.66 Another string
I want to load this guy into a vector of vectors, since I do not know how
long it may be. I think I have to have a vector of vectors of strings, and
then extract the doubles later(?):
std::vector<std ::vector<std::s tring> > m_data_vec;
I started off with this skeletal function, but Im not sure how to parse the
line for tabs and newlines, and stuff the elements into the vector. Is it
better to read in the whole line then parse it? Can I parse it on the fly?
How?
void MyClass::ReadTS V(const* filename)
{
using namespace std;
ifstream infile(filename );
if (!infile) {
cout << "unable to load file" << endl;
}
// Now what?
}
Thanks,
Bryan
Comment