00001 #include <iostream> 00002 #include <fstream> 00003 #include <string> 00004 #include "../Interface/main.h" 00005 #include "../common/csvparser.h" 00006 #include "../common/filereader.h" 00007 #include "../PartB/yieldCurve.h" 00008 00009 using namespace std; 00010 00011 /* Added some modifications to integrate with terreneuve - alokem */ 00012 00013 /* 00014 Copyright (c) 2004, Mayukh Bose 00015 All rights reserved. 00016 00017 Redistribution and use in source and binary forms, with or without 00018 modification, are permitted provided that the following conditions are 00019 met: 00020 00021 * Redistributions of source code must retain the above copyright notice, 00022 this list of conditions and the following disclaimer. 00023 00024 * Redistributions in binary form must reproduce the above copyright 00025 notice, this list of conditions and the following disclaimer in the 00026 documentation and/or other materials provided with the distribution. 00027 00028 * Neither the name of Mayukh Bose nor the names of other 00029 contributors may be used to endorse or promote products derived from 00030 this software without specific prior written permission. 00031 00032 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00033 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00034 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00035 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00036 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00037 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00038 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00039 DATA, OR PROFITS; OR BUSINESS interRUPTION) HOWEVER CAUSED AND ON ANY 00040 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00041 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00042 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00043 */ 00044 00045 bool mainfilereader(void) { 00046 bool result = true; 00047 00048 result &= fr_basic(); 00049 00050 return result; 00051 } 00052 00053 bool fr_basic(void) 00054 { 00055 string sLine; 00056 string sCol1, sCol3, sCol4; 00057 double fCol2; 00058 int iCol5, iCol6; 00059 00060 // string fullpath = string(globaldatadir) + "sample.csv"; 00061 string fullpath = FileReader::getdatadirasstring() + "sample.csv"; 00062 00063 00064 CSVParser parser; 00065 00066 if (!FileReader::fileexists(fullpath)) { 00067 cout << "could not find file " << fullpath << endl; 00068 return false; 00069 } 00070 00071 ifstream infile(fullpath.c_str()); 00072 while (!infile.eof()) { 00073 getline(infile, sLine); // Get a line 00074 if (sLine == "") 00075 continue; 00076 00077 parser << sLine; // Feed the line to the parser 00078 00079 // Now extract the columns from the line 00080 parser >> sCol1 >> fCol2 >> sCol3; 00081 parser >> sCol4 >> iCol5; 00082 parser >> iCol6; 00083 00084 cout << "Column1: " << sCol1 << endl 00085 << "Column2: " << fCol2 << endl 00086 << "Column3: " << sCol3 << endl 00087 << "Column4: " << sCol4 << endl 00088 << "Column5: " << iCol5 << endl 00089 << "Column6: " << iCol6 << endl 00090 << endl; 00091 } 00092 infile.close(); 00093 00094 // check one value... 00095 return (iCol6 == 63); 00096 } 00097