STK::ImportFromCsv Class Reference
[project DManager (Data Management)]

import data from a Csv File. More...

#include <STK_ImportExportCsv.h>

List of all members.

Public Member Functions

 ImportFromCsv (const ReadWriteCsv &import)
virtual ~ImportFromCsv ()
void eraseReadWriteCsv ()
DataFrame *const & getDataFrame () const

Protected Attributes

DataFrameptr_data_


Detailed Description

A ImportFromCsv object create a ReadWriteCsv of string from the stream given in the constructor and allow to convert the string into a predefined type.

Definition at line 121 of file STK_ImportExportCsv.h.


Constructor & Destructor Documentation

STK::ImportFromCsv::ImportFromCsv ( const ReadWriteCsv import  ) 

The default constructor. Instantiates an instance of ImportFromCvs with a readWriteCsv.

Parameters:
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]

Dtor.

Definition at line 121 of file STK_ImportExportCsv.cpp.

00122 { }


Member Function Documentation

void STK::ImportFromCsv::eraseReadWriteCsv (  )  [inline]

delete the ReadWriteCsv.

Definition at line 143 of file STK_ImportExportCsv.h.

References ptr_data_.

00144     { delete ptr_data_;
00145       ptr_data_ = (DataFrame*)NULL;
00146     }

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_;}


Member Data Documentation

A ptr on the data read in the ReadWriteCsv.

Definition at line 126 of file STK_ImportExportCsv.h.

Referenced by eraseReadWriteCsv(), getDataFrame(), and ImportFromCsv().


The documentation for this class was generated from the following files:

Generated on Fri Sep 25 10:31:00 2009 for STK++ by  doxygen 1.5.8