![]() |
aGrUM
0.16.0
|
The class for initializing DatabaseTable and RawDatabaseTable instances from CSV files. More...
#include <agrum/learning/database/DBInitializerFromCSV.h>
Public Member Functions | |
Constructors / Destructors | |
DBInitializerFromCSV (const std::string filename, bool fileContainsNames=true, const std::string delimiter=",", const char commentmarker='#', const char quoteMarker='"', const allocator_type& alloc = allocator_type()) | |
default constructor More... | |
DBInitializerFromCSV (const DBInitializerFromCSV< ALLOC > &from) | |
copy constructor More... | |
DBInitializerFromCSV (const DBInitializerFromCSV< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
DBInitializerFromCSV (DBInitializerFromCSV< ALLOC > &&from) | |
move constructor More... | |
DBInitializerFromCSV (DBInitializerFromCSV< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual DBInitializerFromCSV< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual DBInitializerFromCSV< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~DBInitializerFromCSV () |
destructor More... | |
Operators | |
DBInitializerFromCSV< ALLOC > & | operator= (const DBInitializerFromCSV< ALLOC > &from) |
copy operator More... | |
DBInitializerFromCSV< ALLOC > & | operator= (DBInitializerFromCSV< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
const std::vector< std::string, ALLOC< std::string > > & | variableNames () |
returns the names of the variables in the input dataset More... | |
template<template< template< typename > class > class DATABASE> | |
void | fillDatabase (DATABASE< ALLOC > &database, const bool retry_insertion=false) |
fills the rows of the database table More... | |
std::size_t | throwingColumn () const |
This method indicates which column filling raised an exception, if any, during the execution of fillDatabase. More... | |
allocator_type | getAllocator () const |
returns the allocator used More... | |
Public Types | |
using | allocator_type = ALLOC< std::string > |
type for the allocators passed in arguments of methods More... | |
enum | InputType : char { InputType::STRING, InputType::DBCELL } |
the enumeration indicating the type of the data the IDBInitializer expects as input data More... | |
Protected Member Functions | |
virtual std::vector< std::string, ALLOC< std::string > > | _variableNames () final |
returns the names of the variables More... | |
virtual const std::vector< std::string, ALLOC< std::string > > & | _currentStringRow () final |
returns the content of the current row using strings More... | |
virtual bool | _nextRow () final |
indicates whether there is a next row to read (and point on it) More... | |
virtual const DBRow< DBCell, ALLOC > & | _currentDBCellRow () |
asks the child class for the content of the current row using dbcells More... | |
The class for initializing DatabaseTable and RawDatabaseTable instances from CSV files.
In aGrUM, the usual way to create DatabaseTable instances used by learning algorithms is to use the 4-step process below:
Definition at line 132 of file DBInitializerFromCSV.h.
using gum::learning::DBInitializerFromCSV< ALLOC >::allocator_type = ALLOC< std::string > |
type for the allocators passed in arguments of methods
Definition at line 135 of file DBInitializerFromCSV.h.
|
stronginherited |
the enumeration indicating the type of the data the IDBInitializer expects as input data
Enumerator | |
---|---|
STRING | |
DBCELL |
Definition at line 121 of file IDBInitializer.h.
gum::learning::DBInitializerFromCSV< ALLOC >::DBInitializerFromCSV | ( | const std::string | filename, |
bool | fileContainsNames = true , |
||
const std::string | delimiter = "," , |
||
const char | commentmarker = '#' , |
||
const char | quoteMarker = '"' , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
default constructor
filename | the name of the CSV file |
fileContainsNames | a Boolean indicating whether the first line of the CSV file contains the names of the columns |
delimiter | the character that acts as the column separator in the CSV file |
commentmarker | the character that marks the beginning of a comment |
quoteMarker | the character that is used to quote the sentences in the CSV file |
alloc | the allocator used by all the methods |
gum::learning::DBInitializerFromCSV< ALLOC >::DBInitializerFromCSV | ( | const DBInitializerFromCSV< ALLOC > & | from | ) |
copy constructor
the new initializer points to the same file as from, but it reparses it from scratch.
gum::learning::DBInitializerFromCSV< ALLOC >::DBInitializerFromCSV | ( | const DBInitializerFromCSV< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
the new initializer points to the same file as from, but it reparses it from scratch.
gum::learning::DBInitializerFromCSV< ALLOC >::DBInitializerFromCSV | ( | DBInitializerFromCSV< ALLOC > && | from | ) |
move constructor
gum::learning::DBInitializerFromCSV< ALLOC >::DBInitializerFromCSV | ( | DBInitializerFromCSV< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
protectedvirtualinherited |
asks the child class for the content of the current row using dbcells
If the child class parses DBRows, this method should be overloaded
|
finalprotectedvirtual |
returns the content of the current row using strings
Reimplemented from gum::learning::IDBInitializer< ALLOC >.
|
finalprotectedvirtual |
indicates whether there is a next row to read (and point on it)
Implements gum::learning::IDBInitializer< ALLOC >.
|
finalprotectedvirtual |
returns the names of the variables
Implements gum::learning::IDBInitializer< ALLOC >.
|
virtual |
virtual copy constructor
Implements gum::learning::IDBInitializer< ALLOC >.
|
virtual |
virtual copy constructor with a given allocator
Implements gum::learning::IDBInitializer< ALLOC >.
|
inherited |
fills the rows of the database table
This method may raise exceptions when trying to insert new rows into the database table. See Method insertRow() of the database table.
Referenced by gum::learning::genericBNLearner::__readFile(), gum::learning::genericBNLearner::Database::Database(), and gum::learning::readFile().
|
inherited |
returns the allocator used
DBInitializerFromCSV< ALLOC >& gum::learning::DBInitializerFromCSV< ALLOC >::operator= | ( | const DBInitializerFromCSV< ALLOC > & | from | ) |
copy operator
the initializer points to the same file as from, but it reparses it from scratch.
DBInitializerFromCSV< ALLOC >& gum::learning::DBInitializerFromCSV< ALLOC >::operator= | ( | DBInitializerFromCSV< ALLOC > && | from | ) |
move operator
the initializer points to the same file as from, but it reparses it from scratch.
|
inherited |
This method indicates which column filling raised an exception, if any, during the execution of fillDatabase.
|
inherited |
returns the names of the variables in the input dataset
Referenced by gum::learning::genericBNLearner::__readFile(), gum::learning::genericBNLearner::Database::Database(), and gum::learning::readFile().