neuralib.tools.gspread.GoogleSpreadSheet

class neuralib.tools.gspread.GoogleSpreadSheet[source]

Bases: object

Gspread module wrapper to access google spreadsheet

service_account_path = ...  # The path to the service account json file
sh = GoogleSpreadSheet('test_sheet', service_account_path)

# get a worksheet from the spreadsheet
ws = sh[WORK_SHEET_NAME]
__init__(name, service_account_path, primary_key='Data')[source]
Parameters:
  • name (str) – name of the spreadsheet

  • service_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

Methods

__init__(name, service_account_path[, ...])

get_worksheet(page)

Get the worksheet.

has_worksheet(page)

If has the worksheet, implement also in __contains__()

Attributes

title

SpreadSheetName

worksheet_list

list of WorkPageName

__init__(name, service_account_path, primary_key='Data')[source]
Parameters:
  • name (str) – name of the spreadsheet

  • service_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

property title: str

SpreadSheetName

property worksheet_list: list[str]

list of WorkPageName

has_worksheet(page)[source]

If has the worksheet, implement also in __contains__()

Parameters:

page (str)

Return type:

bool

get_worksheet(page)[source]

Get the worksheet. implement also in __get_item__()

Parameters:

page (str)

Return type:

GoogleWorkSheet