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
Methods
__init__(worksheet[, primary_key])clear()Clears all cells in the worksheet
get_cell(data, head[, value_render_option])Get data from a cell
get_range_value(a1_range_notation)get values from range notation.
of(name, page, service_account_path[, ...])Get a worksheet from spreadsheet
Worksheet to pandas dataframe
Worksheet to polar dataframe
update(range_name[, values])Sets values in a cell range of the sheet
update_cell(data, head, value)Update value in a cell
values(head)get list of value from header
Attributes
list of worksheet header
list of primary key of the worksheet
WorkPageName- __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 | PathLike[str]) – 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:
- 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: