neuralib.tools.gspread.GoogleWorkSheet
- class neuralib.tools.gspread.GoogleWorkSheet[source]
Bases:
object- __init__(worksheet, primary_key='Data')[source]
- Parameters:
worksheet (Worksheet) –
gspread.Worksheetprimary_key (str | tuple[str, ...]) –
Primary key of the worksheet.
If str type, it must be one of the column name.
If tuple str type, the primary key is join using “_” per row
- classmethod of(name, page, service_account_path, primary_key='Data')[source]
Get a worksheet from spreadsheet
- Parameters:
name (str) –
SpreadSheetNamepage (str) –
WorkPageNameservice_account_path (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – The path to the service account json file
primary_key (str | tuple[str, ...]) –
Primary key of the worksheet.
If str type, it must be one of the column name.
If tuple str type, the primary key is join using “_” per row
- Returns:
GoogleWorkSheet- Return type:
Self
- property title: str
WorkPageName
- property headers: list[str]
list of worksheet header
- property primary_key_list: list[str]
list of primary key of the worksheet
- get_range_value(a1_range_notation)[source]
get values from range notation. i.e., B1:S1 to get the list of content.
If get values from 2D, the return order would be first column-wise, then row-wise
- Parameters:
a1_range_notation (str)
- Return type:
list[Any]
- get_cell(data, head, value_render_option='FORMATTED_VALUE')[source]
Get data from a cell
- Parameters:
data (None | int | str | slice | list[int] | list[str] | ndarray) –
DataIndexhead (str) – header name
value_render_option (Literal['FORMATTED_VALUE', 'UNFORMATTED_VALUE', 'FORMULA']) –
VALUE_RENDER_OPT: {‘FORMATTED_VALUE’, ‘UNFORMATTED_VALUE’, ‘FORMULA’}
- Returns: