Sheets¶
Class which allows for Google Sheets to be used as paramater set database.
Note: if you have data in the first row, you must have entries in some other row.
-
class
dapt.sheets.
Sheet
(*args, **kwargs)¶ An interface for accessing and setting paramater set data. You must either provide a Config object or client_id and client_secret.
Keyword Arguments: - config (Config) – A Config object which contains the client_id and client_secret.
- spreedsheetID (str) – the Google Sheets ID
- creds_file (str) – the path to the file containing the Google API credentials. Default is
credentials.json
. - sheet_id (int) – the the sheet id to use (0 by default)
-
get_key_index
(column_key)¶ Get the column index given the key.
Parameters: column_key (str) – the key to find the index of Returns: The index or -1 if it could not be determined.
-
get_keys
()¶ Get the keys of the paramater set
Returns: Array of strings with each element being a key (order is preserved if possible)
-
get_row_index
(column_key, row_value)¶ Get the row index given the column to look through and row value to match to.
Parameters: - column_key (str) – the key to find the index of
- row_value (str) – the value of the cell to fine
Returns: The index or -1 if it could not be determined.
-
get_table
()¶ Get the table from the database.
Returns: An array with each element being a dictionary of the key-value pairs for the row in the database.
-
update_cell
(row_id, key, value)¶ Get the keys of the paramater set
Parameters: - row_id (str) – the row id to replace
- key (str) – the key of the value to replace
- value (str) – the value to insert into the cell
Returns: A boolean that is True if successfully inserted and False otherwise.
-
update_row
(row_id, values)¶ Get the row of the paramater set
Parameters: - row_id (int) – the row id to replace
- values (OrderedDict) – the key-value pairs that should be inserted
Returns: A boolean that is True if successfully inserted and False otherwise.
-
worksheet
(*args, **kwargs)¶ Get a Google Sheet object. You can give a worksheet id or title or nothing (get values from Config file). If the you give a worksheet id and title then the id will be used.
Keyword Arguments: - id (str) – the Google Sheets worksheet id
- title (int) – the Google Sheet worksheet title
Returns: A Google Sheet worksheet