http://quantlib.414.s1.nabble.com/picking-the-correct-row-in-a-map-string-vector-string-tp13896p13902.html
Hi Kyle,
thanks a lot for your response
I am using QuantLib in this project mostly to handle dates, calendars and also for interpolation and to gather some statistics.
My starting point is few csv files which contains my input data. Couple of these files contain hundreds of rows (even thousands). But that is not a problem.
As you might have guessed by now, these files contain various types of data, i.e. string, double, Date, etc.
I have been using Boost tokenizer to parse the data from these files and then storing the data into maps and in one case multimap (because this file contains history of rates for various currencies but same dates).
That being said, once the data is stored, I wish to compute a fully interpolated vol curve, compute expiry (which is easy using QuantLib), compute standard deviation using the vol and expiry (which is just a simple formula).
It certainly seems like for the example above, I should abandon my method of storing the data into a map <string, vector <string> > and replace it with map < string, Struct> .
would you agree?
thanks
Pavan
fyi,
this is how I parse the data and store the data line by line into the current map<string, vector <string> > .
typedef tokenizer <escaped_list_separator <char> > Tokenizer;
vector <string> vec;
//the actual data structure
map<string,vector<string> > testmap;
while (getline(Ports,line))
{
Tokenizer tok(line);
vec.assign(tok.begin(),tok.end());
string key = vec[0];
vector <string>row;
/*vector <string>::iterator start = row.begin()+1, end = row.end();*/
for (int i=1;i<vec.size();i++)
{
row.push_back(vec[i]);
}
//put the sample data into the map
testmap[key]=row;
//output the data from the map
//cout<<testmap[key].at(0)<<" " << testmap[key].at(1)<<" " << testmap[key].at(12)<<endl; // There are a total of 13 mapped values to a single trade it in this file.
/*if (vec.size() < 3) continue;*/
/*copy (vec.begin(),vec.end(), ostream_iterator<string> (cout," "));*/
}
much more. Get web development skills now with LearnDevNow -