sorcha.readers.DatabaseReader

Classes

DatabaseReader

A class to read in object data stored in a sqlite database.

Module Contents

class DatabaseReader(intermdb, **kwargs)[source]

Bases: sorcha.readers.ObjectDataReader.ObjectDataReader

A class to read in object data stored in a sqlite database.

intermdb[source]
get_reader_info()[source]

Return a string identifying the current reader name and input information (for logging and output).

Returns:

name -- The reader information.

Return type:

string

_read_rows_internal(block_start=0, block_size=None, **kwargs)[source]

Reads in a set number of rows from the input.

Parameters:
  • block_start (integer, optional) -- The 0-indexed row number from which to start reading the data. For example in a CSV file block_start=2 would skip the first two lines after the header and return data starting on row=2. Default=0

  • block_size (int, optional) -- the number of rows to read in. Use block_size=None to read in all available data. A non-None block size must be provided if block_start > 0. Default = None

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

res_df -- dataframe of the object data.

Return type:

pandas dataframe

Notes

A non-None block size must be provided if block_start > 0.

_read_objects_internal(obj_ids, **kwargs)[source]

Read in a chunk of data for given object IDs.

Parameters:
  • obj_ids (list) -- A list of object IDs to use.

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

res_df -- The dataframe for the object data.

Return type:

pandas dataframe

_process_and_validate_input_table(input_table, **kwargs)[source]

Perform any input-specific processing and validation on the input table. Modifies the input dataframe in place.

Notes

The base implementation includes filtering that is common to most input types. Subclasses should call super.process_and_validate() to ensure that the ancestor’s validation is also applied.

Parameters:
  • input_table (pandas dataframe) -- A loaded table.

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

input_table -- Returns the input dataframe modified in-place.

Return type:

pandas dataframe