CsvFileConn: CSV File connector class.

CsvFileConnR Documentation

CSV File connector class.

Description

CSV File connector class.

CSV File connector class.

Details

This is the abstract connector class for all CSV file databases.

Super classes

biodb::BiodbConnBase -> biodb::BiodbConn -> CsvFileConn

Methods

Public methods

Inherited methods

Method new()

New instance initializer. Connector classes must not be instantiated directly. Instead, you must use the createConn() method of the factory class.

Usage
CsvFileConn$new(...)
Arguments
...

All parameters are passed to the super class initializer.

Returns

Nothing.


Method getCsvQuote()

Gets the characters used to delimit quotes in the CSV database file.

Usage
CsvFileConn$getCsvQuote()
Returns

The characters used to delimit quotes as a single character value.


Method setCsvQuote()

Sets the characters used to delimit quotes in the CSV database file.

Usage
CsvFileConn$setCsvQuote(quote)
Arguments
quote

The characters used to delimit quotes as a single character value.

You

may specify several characters. Example \"\\"'\".

Returns

Nothing.


Method getCsvSep()

Gets the current CSV separator used for the database file.

Usage
CsvFileConn$getCsvSep()
Returns

The CSV separator as a character value.


Method setCsvSep()

Sets the CSV separator to be used for the database file. If this method is called after the loading of the database, it will throw an error.

Usage
CsvFileConn$setCsvSep(sep)
Arguments
sep

The CSV separator as a character value.

Returns

Nothing.


Method getFieldNames()

Get the list of all biodb fields handled by this database.

Usage
CsvFileConn$getFieldNames()
Returns

A character vector of the biodb field names.


Method hasField()

Tests if a field is defined for this database instance.

Usage
CsvFileConn$hasField(field)
Arguments
field

A valid Biodb entry field name.

Returns

TRUE of the field is defined, FALSE otherwise.


Method addField()

Adds a new field to the database. The field must not already exist. The same single value will be set to all entries for this field. A new column will be written in the memory data frame, containing the value given.

Usage
CsvFileConn$addField(field, value)
Arguments
field

A valid Biodb entry field name.

value

The value to set for this field.

Returns

Nothing.


Method getFieldColName()

Get the column name corresponding to a Biodb field.

Usage
CsvFileConn$getFieldColName(field)
Arguments
field

A valid Biodb entry field name. This field must be defined for this database instance.

Returns

The column name from the CSV file.


Method setField()

Sets a field by making a correspondence between a Biodb field and one or more columns of the loaded data frame.

Usage
CsvFileConn$setField(field, colname, ignore.if.missing = FALSE)
Arguments
field

A valid Biodb entry field name. This field must not be already defined for this database instance.

colname

A character vector containing one or more column names from the CSV file.

ignore.if.missing

Deprecated parameter.

Returns

Nothing.


Method getFieldsAndColumnsAssociation()

Gets the association between biodb field names and CSV file column names.

Usage
CsvFileConn$getFieldsAndColumnsAssociation()
Returns

A list with names being the biodb field names and values being a character vector of column names from the CSV file.


Method getUnassociatedColumns()

Gets the list of unassociated column names from the CSV file.

Usage
CsvFileConn$getUnassociatedColumns()
Returns

A character vector containing column names.


Method print()

Prints a description of this connector.

Usage
CsvFileConn$print()
Returns

Nothing.


Method setDb()

Sets the database directly from a data frame. You must not have set the database previously with the URL parameter.

Usage
CsvFileConn$setDb(db)
Arguments
db

A data frame containing your database.

Returns

Nothing.


Method setIgnoreUnassignedColumns()

Tells the connector to ignore or not the columns found in the CSV file for which no assignment were found.

Usage
CsvFileConn$setIgnoreUnassignedColumns(ignore)
Arguments
ignore

Set to TRUE to ignore the unassigned columns, and to FALSE otherwise.

Returns

Nothing.


Method clone()

The objects of this class are cloneable with this method.

Usage
CsvFileConn$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Super classes BiodbConn, and sub-classes CompCsvFileConn, MassCsvFileConn.

Examples

# Create an instance with default settings:
mybiodb <- biodb::newInst()

# Get a connector that inherits from CsvFileConn:
chebi_file <- system.file("extdata", "chebi_extract.tsv", package="biodb")
conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi_file)

# Get an entry
e <- conn$getEntry('1018')

# Terminate instance.
mybiodb$terminate()


pkrog/biodb documentation built on Nov. 29, 2022, 4:24 a.m.