corrdata module
- class corrdata.CorrData[source]
Bases:
object
Class to manipulate the CorrDB-class’es data dict structure.
- getFieldCount(data={}, field='dummy', values=[], omitblanks=True, ignorecase=False, dependent='', depvalue=[]) int [source]
Get number of occurences of a given value in a given field of the CorrDB data-structure.
- Parameters:
data (dict) – The CorrDB data-structure to go through and count occurences.
field (str) – Name of the field to search for the given value.
values (list) – String or list of value(s) to search for and count.
omitblanks (bool) – Specifies if the search for values are to omit blanks. Optional. Defaults to True. If omitblanks is False it will search for the value “*N/A (Other)*” (see the getFieldUniqueValues()-method)
ignorecase (bool) – Specifies if the search is to ignore case. Optional. Default to False.
dependent (str) – Specifies if the counting is dependent upon given field has a certain value or not. Optional. Default to blank, which means False. If non-blank it specified the field that holds the value(s) that the search are dependent upon.
depvalue (list) – String or list of value(s) that must be matched (one instance of) before counting is performed on a given row. Optional. Defaults to empty list.
- Returns:
The number of matches of the given conditions set.
- Return type:
int
- getFieldUniqueValues(data, field, omitblanks=True, encode=False) list [source]
Get all unique values for a given data field.
- Parameters:
data (dict) – CorrDB dict-structure to search for unique values.
field (str) – Which field to search for unique values in the CorrDB dict-structure.
omitblanks (bool) – Omit field values that are blank and do not add them as unique. Optional. Defaults to True. If set to False, the blank value will be returned as unique value: “*N/A (Other)*”.
- Returns:
List of unique values found in the CorrDB data structure.
- Return type:
list
- getRowCount(data={}) int [source]
Returns the number of rows in a CorrDB data dict-structure
- Parameters:
data (dict) – The CorrDB data dict-structure to count rows of.
- Returns:
Returns the number of rows in a CorrDB data dict-structure
- Return type:
int
- rangeList(rfrom, rto, asStr=False) list [source]
Create a list of values in a given range, either as integers or strings.
- Parameters:
rfrom (int) – Start of range to create list values of.
rto (int) – End of range to create list values of. Values will be created including this value.
asStr (bool) – Defines if returned list will have string type values or not. Optional. Defaults to False and values will be integers.
- Returns:
List of values that are in the range requested by input parameters.
- Return type:
list