#include <STK_ImportExportCsv.h>
Public Member Functions | |
| ImportFromCsv (const ReadWriteCsv &import) | |
| virtual | ~ImportFromCsv () |
| void | eraseReadWriteCsv () |
| DataFrame *const & | getDataFrame () const |
Protected Attributes | |
| DataFrame * | ptr_data_ |
Definition at line 121 of file STK_ImportExportCsv.h.
| STK::ImportFromCsv::ImportFromCsv | ( | const ReadWriteCsv & | import | ) |
The default constructor. Instantiates an instance of ImportFromCvs with a readWriteCsv.
| import | the ReadWriteCsv to import |
Definition at line 77 of file STK_ImportExportCsv.cpp.
References STK::Variable< TYPE >::importString(), ptr_data_, STK::DataFrame::pushBackVariable(), and STK::Variable< TYPE >::size().
00078 { 00079 // set Rows Dimensions, there is no cols 00080 ptr_data_ = new DataFrame(); 00081 00082 // for each field Try a numeric conversion 00083 for (Integer j =import.first(); j <=import.last(); j++) 00084 { 00085 // Count the number of successfull conversion 00086 Integer nSuccess; 00087 // get dimensions of the variable 00088 Inx range = import[j].getRange(); 00089 String name = import[j].getName(); 00090 // create a discrete variable 00091 Variable<Integer> * pvInteger = new Variable<Integer> (range, name); 00092 // try to ConvertType strings to Integer 00093 pvInteger ->importString(nSuccess, import[j]); 00094 // test number of successful conversion 00095 if (nSuccess == pvInteger ->size()) 00096 { // if no failure add variable to the dataframe 00097 ptr_data_->pushBackVariable(pvInteger ); 00098 } 00099 else 00100 { 00101 delete pvInteger ; // delete varInteger 00102 Variable<Real>* pvReal = new Variable<Real>(range, name); 00103 // try to ConvertType strings to Real 00104 pvReal->importString(nSuccess, import[j]); 00105 // test number of successful conversion 00106 if (nSuccess == pvReal->size()) 00107 { // if no failure add variable to the dataframe 00108 ptr_data_->pushBackVariable(pvReal); 00109 } 00110 else 00111 { 00112 delete pvReal; // delete varReal 00113 Variable<String>* pvString = new Variable<String>(import[j]); 00114 ptr_data_->pushBackVariable(pvString); 00115 } 00116 } 00117 } 00118 }
| STK::ImportFromCsv::~ImportFromCsv | ( | ) | [virtual] |
| void STK::ImportFromCsv::eraseReadWriteCsv | ( | ) | [inline] |
delete the ReadWriteCsv.
Definition at line 143 of file STK_ImportExportCsv.h.
References ptr_data_.
| DataFrame* const& STK::ImportFromCsv::getDataFrame | ( | ) | const [inline] |
Return a ptr on the the data read.
Definition at line 152 of file STK_ImportExportCsv.h.
References ptr_data_.
00153 { return ptr_data_;}
DataFrame* STK::ImportFromCsv::ptr_data_ [protected] |
A ptr on the data read in the ReadWriteCsv.
Definition at line 126 of file STK_ImportExportCsv.h.
Referenced by eraseReadWriteCsv(), getDataFrame(), and ImportFromCsv().
1.5.8