Hi all, I am using boost tokenizer to parse the data from a csv file.
However, once the data has been parsed, I wish to store each line as a record. For example, lets say one line is as follows:
Trade ID, counterparty, currency, tradetype, notional, ..expirydate 20 bank A EUR Option 100 12/26/2012 I want to store this line as a record so that when I want to , I can retreive all of these attributes related to a particular trade-id. Its like a lookup table/map but with one key and many mapped values. I have an entire file full of these types of rows.
Is there something in STL or Boost or QuantLib that will allow me to store so many attributes that map to one key like a trade-id? I was thinking about about a multimap. any ideas please? thanks
Pavan ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Why not simply define a struct and use a map to associate a struct
instance to a key? Luigi On Wed, Dec 26, 2012 at 7:02 PM, Pavan Shah <[hidden email]> wrote: > Hi all, > I am using boost tokenizer to parse the data from a csv file. > However, once the data has been parsed, I wish to store each line as a > record. For example, lets say one line is as follows: > > Trade ID, counterparty, currency, tradetype, notional, ..expirydate > 20 bank A EUR Option 100 > 12/26/2012 > > I want to store this line as a record so that when I want to , I can > retreive all of these attributes related to a particular trade-id. Its like > a lookup table/map but with one key and many mapped values. I have an > entire file full of these types of rows. > > Is there something in STL or Boost or QuantLib that will allow me to store > so many attributes that map to one key like a trade-id? > > I was thinking about about a multimap. > any ideas please? > > thanks > Pavan > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Luigi, if I understand you , i think you are suggesting that for each key in the map, have the key point to an instance of a struct that contains rest of the elements in that row.
Is that right? Keep in mind I have to do this for hundreds of lines. Pavan On Fri, Dec 28, 2012 at 5:22 AM, Luigi Ballabio <[hidden email]> wrote: Why not simply define a struct and use a map to associate a struct ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Yes, that's what I'm suggesting. Just loop over the lines, and for
each one create the instance and store it in the map. Hundreds is not that much. Each instance won't weigh more than a few dozens of bytes. Luigi On Fri, Dec 28, 2012 at 6:15 PM, Pavan Shah <[hidden email]> wrote: > Luigi, > if I understand you , i think you are suggesting that for each key in the > map, have the key point to an instance of a struct that contains rest of the > elements in that row. > Is that right? > > Keep in mind I have to do this for hundreds of lines. > > Pavan > > > On Fri, Dec 28, 2012 at 5:22 AM, Luigi Ballabio <[hidden email]> > wrote: >> >> Why not simply define a struct and use a map to associate a struct >> instance to a key? >> >> Luigi >> >> On Wed, Dec 26, 2012 at 7:02 PM, Pavan Shah <[hidden email]> wrote: >> > Hi all, >> > I am using boost tokenizer to parse the data from a csv file. >> > However, once the data has been parsed, I wish to store each line as a >> > record. For example, lets say one line is as follows: >> > >> > Trade ID, counterparty, currency, tradetype, notional, ..expirydate >> > 20 bank A EUR Option 100 >> > 12/26/2012 >> > >> > I want to store this line as a record so that when I want to , I can >> > retreive all of these attributes related to a particular trade-id. Its >> > like >> > a lookup table/map but with one key and many mapped values. I have an >> > entire file full of these types of rows. >> > >> > Is there something in STL or Boost or QuantLib that will allow me to >> > store >> > so many attributes that map to one key like a trade-id? >> > >> > I was thinking about about a multimap. >> > any ideas please? >> > >> > thanks >> > Pavan >> > >> > >> > ------------------------------------------------------------------------------ >> > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial >> > Remotely access PCs and mobile devices and provide instant support >> > Improve your efficiency, and focus on delivering more value-add services >> > Discover what IT Professionals Know. Rescue delivers >> > http://p.sf.net/sfu/logmein_12329d2d >> > _______________________________________________ >> > QuantLib-users mailing list >> > [hidden email] >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > > > ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Peter, Luigi, thank you both
I was able to do this in just few lines. Pavan
On Fri, Dec 28, 2012 at 9:18 AM, Luigi Ballabio <[hidden email]> wrote: Yes, that's what I'm suggesting. Just loop over the lines, and for ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi guys,
just a quick question, if I have a map such as map<string , vector <string> > Input_Vols
and vector <string> has 2 elements. First element is a date in string format and second one is a price. I am trying to convert each date from string format into a QuantLib date.
I am trying to use DateParser.parseISO method from QuantLib to convert all string dates in the map into QuantLib dates.
However, the compiler complains. This is the error. Error 2 error C2275: 'QuantLib::DateParser' : illegal use of this type as an expression
Here is my piece of code. map<string, vector <string> >::iterator iter=Input_Vols.find("EURUSDV1M CMPN Curncy");
while(iter!=Input_Vols.end()) {
(*iter).second[0]=DateParser.parseISO((*iter).second[0]); ++iter;
} What am I doing wrong?
thanks pavan On Fri, Dec 28, 2012 at 10:34 AM, Pavan Shah <[hidden email]> wrote:
------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Pavan,
try DateParser::parseISO( ) instead. This is a static function defined in the class DateParser. Peter Am 29.12.2012 00:25, schrieb Pavan Shah:
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122912 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I made the correction. But the compiler gives me this error: Error 29 error LNK1104: cannot open file 'QuantLib-vc100-mt-gd.lib'
Here is my corrected version of code: map<string, vector <string> >::iterator iter=Input_Vols.find("EURUSDV1M CMPN Curncy");
while(iter!=Input_Vols.end())
{
DateParser::parseISO((*iter).second[0]);
++iter;
} I am using Visual Studio 2010 to compile. Two questions:
1)is there anything wrong with my code above? 2)do i need to change something in my project properties? thanks pavan On Sat, Dec 29, 2012 at 4:42 AM, Peter Caspers <[hidden email]> wrote:
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Pavan, first you should make sure the
the file in question is properly generated. Usually it is located
in some subfolder named 'lib'. If it is there, you have to add
this folder to the 'linker / additional library directories'
property of your project that you want to link against the
library.
Happy new year Peter Am 31.12.2012 23:02, schrieb Pavan Shah:
------------------------------------------------------------------------------ Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS and more. Get SQL Server skills now (including 2012) with LearnDevNow - 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only - learn more at: http://p.sf.net/sfu/learnmore_122512 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I am able to get around that error. However, what is the best way to convert a string date that is stored in a vector <string> within a map using QuantLib's dateparser class?
Something seems wrong in my function below but I can't figure out what exactly. void Imp_Vols::Conv_Data_Vols() { Imp_Vols Test2; /*Test2.total_obs();*/ map<string , vector <string> > Input_Vols=Test2.Load_Imp_Vols();
map<string, vector <string> >::iterator iter=Input_Vols.find("EURUSDV1M CMPN Curncy"); while(iter!=Input_Vols.end())
{ DateParser::parseISO((*iter).second[0]); ++iter;
} cout<<"The date of the file is: "<< (*iter).second[0]<<endl;
} Pavan On Tue, Jan 1, 2013 at 4:15 AM, Peter Caspers <[hidden email]> wrote:
------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Pavan, I do not understand your code
below. I guess there are many ways to get what you want. There is
nothing special in converting a string to a date even if the
former is stored within a vector which is a mapped value, e.g.
std::map<std::string, std::vector<std::string>> data; ... Date d; if(data.count(myKey)>0) DateParser::parseISO(data[myKey][index]); else ... with myKey a string and index an unsigned int. Hope that helps. Peter Am 02.01.2013 19:14, schrieb Pavan Shah:
------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
figured it out thanks Peter
On Wed, Jan 2, 2013 at 12:41 PM, Peter Caspers <[hidden email]> wrote:
------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |