CsvFileConn-class {biodb} | R Documentation

## CSV File connector class.

### Description

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

### Methods

`addField(field, value)`

  :

  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.

  field: A valid Biodb entry field name.

  value: The value to set for this field.

  Returned value: None.

`getCsvQuote()`

  :

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

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

`getCsvSep()`

  :

  Gets the current CSV separator used for the database file.

  Returned value: The CSV separator as a character value.

`getEntryContentFromDb(entry.id)`

  :

  Get the contents of entries directly from the database. A direct request or an access to the database will be made in order to retrieve the contents. No access to the biodb cache system will be made.

  entry.id: A character vector with the IDs of entries to retrieve.

  Returned value: A character vector, the same size of entry.id, with contents of the requested entries. An NA value will be set for the content of each entry for which the retrieval failed.

`getFieldColName(field)`

  :

  Get the column name corresponding to a Biodb field.

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

  Returned value: The column name from the CSV file.

`getFieldNames()`

  :

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

  Returned value: A character vector of the biodb field names.

`getNbEntries(count = FALSE)`

  :

  Get the number of entries contained in this database.

  count: If set to TRUE and no straightforward way exists to get number of entries, count the output of getEntryIds().

  Returned value: The number of entries in the database, as an integer.

`hasField(field)`

  :

  Tests if a field is defined for this database instance.

  field: A valid Biodb entry field name.

  Returned value: TRUE of the field is defined, FALSE otherwise.

`isSearchableByField(field)`

  :

  Tests if a field can be used to search entries when using methods searchByName() and searchCompound().

  field: The name of the field.

  Returned value: Returns TRUE if the database is searchable using the specified field, FALSE otherwise.

`setCsvQuote(quote)`

  :

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

  quote: The characters used to delimit quotes as a single character value. You may specify several characters. Example: "\"'".

  Returned value: None.

`setCsvSep(sep)`

  :

  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.

  sep: The CSV separator as a character value.

  Returned value: None.

`setDb(db)`

  :

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

  db: A data frame containing your database.

  Returned value: None.

`setField(field, colname, ignore.if.missing = FALSE)`

  :

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

  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.

  Returned value: None.

`show()`

  :

  Prints a description of this connector.

  Returned value: None.

### See Also

Super classes `BiodbConn`, `BiodbWritable`, `BiodbEditable`, 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()

[Package biodb version 1.0.4 Index]