Google Sheets
Actions for handling Google Sheets data
To use this actions you need to configure Google Cloude. See more:
Google CloudModule: implementation.datasources.google_sheets
GoogleSheetsAction
Base Google Sheets action. Subclass of Action.
__init__
Arguments:
client (GoogleCloudClient): Google client that will be used for access.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
GoogleSheetsCreate
Create spreadsheet. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"title" (str): Name of the spreadsheet;
"sheets" (List[str], optional): Sheets names to create. Defaults to ["Sheet1"].
Raises:
Exception: If unable to create spreadsheet.
Returns:
Dict[str, Any]: Expected keys:
"spreadsheet_id" (str): Spreadsheet ID;
GoogleSheetsRead
Read spreadsheet. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"spreadsheet_id" (str): Spreadsheet ID (can be found in url: https://docs.google.com/spreadsheets/d/spreadsheet_id/edit#gid=0);
"cells_range" (str): Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
Raises:
Exception: If unable to read spreadsheet.
Returns:
Dict[str, Any]: Expected keys:
"table" (List[List[Any]]): Table that represents sheet or part of it specified by "cells_range";
GoogleSheetsReadBatch
Read spreadsheet batch. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], List[Dict[str, Any]]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"spreadsheet_id" (str): Spreadsheet ID (can be found in url: https://docs.google.com/spreadsheets/d/spreadsheet_id/edit#gid=0);
"cells_ranges" (List[str]): Ranges of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
Raises:
Exception: If unable to read spreadsheet.
Returns:
List[Dict[str, Any]]: List of items containing tables. Items expected keys:
"table" (List[List[Any]]): Table that represents sheet or part of it specified by "cells_range";
GoogleSheetsWrite
Write to spreadsheet. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"spreadsheet_id" (str): Spreadsheet ID (can be found in url: https://docs.google.com/spreadsheets/d/spreadsheet_id/edit#gid=0);
"cells_range" (str): Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
"value_input_option" (InputOption, optional): Input option can be: InputOption.USER_ENTERED - All inputs treated as input from the user (enabling formatting and formulas), or InputOption.RAW - all inputs as is. Defaults to InputOption.USER_ENTERED.
"table" (List[List[Any]]): Values to add to spreadsheet.
Raises:
Exception: If unable to update spreadsheet.
Returns:
Dict[str, Any]: Expected keys:
"spreadsheet" (Dict[str, Any]): Updated spreadsheet;
GoogleSheetsWriteBatch
Write to spreadsheet batch. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"spreadsheet_id" (str): Spreadsheet ID (can be found in url: https://docs.google.com/spreadsheets/d/spreadsheet_id/edit#gid=0);
"value_input_option" (InputOption, optional): Input option can be: InputOption.USER_ENTERED - All inputs treated as input from the user (enabling formatting and formulas), or InputOption.RAW - all inputs as is. Defaults to InputOption.USER_ENTERED.
"inputs" (List[Dict[str, Any]]): List of write actions. Each action contain:
"cells_range" (str): Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
"table" (List[List[Any]]): Values to add to spreadsheet.
Raises:
Exception: If unable to update spreadsheet.
Returns:
Dict[str, Any]: Expected keys:
"spreadsheet" (Dict[str, Any]): Updated spreadsheet;
GoogleSpreadsheetsAppend
Write to spreadsheet. Subclass of GoogleSheetsAction. Type of GoogleSheetsAction[Dict[str, Any], Dict[str, Any]].
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"spreadsheet_id" (str): Spreadsheet ID (can be found in url: https://docs.google.com/spreadsheets/d/spreadsheet_id/edit#gid=0);
"cells_range" (str): Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
"value_input_option" (InputOption, optional): Input option can be: InputOption.USER_ENTERED - All inputs treated as input from the user (enabling formatting and formulas), or InputOption.RAW - all inputs as is. Defaults to InputOption.USER_ENTERED.
"insert_data_option" (InsertDataOption, optional): Isert data option can be InsertDataOption.OVERWRITE - will overwrite anything after table, or InsertDataOption.INSERT_ROWS - will insert new rows. Defaults to InsertDataOption.OVERWRITE.
"table" (List[List[Any]]): Values to add to spreadsheet.
Raises:
Exception: If unable to update spreadsheet.
Returns:
Dict[str, Any]: Expected keys:
"spreadsheet" (Dict[str, Any]): Updated spreadsheet;
GoogleSheetsClientConfig
Google Sheets default configuration. Subclass of GoogleCloudClientConfig.
__init__
Arguments:
scopes (List[str]): Access scopes. Defaults to ["https://www.googleapis.com/auth/spreadsheets"] (Read and write acess to all spreadsheets).
service (str): Service name. Defaults to "sheets" (Google Spreadsheets service).
version (str): API version. Defaults to "v4".
Dimension
Specify major dimension(i.e. what outer list represents)
ROWS
COLUMNS
InputOption
Specify how input data should be formatted
RAW
Inputs as is
USER_ENTERED
All inputs treated as input from the user (enabling formatting and formulas)
InsertDataOption
How data should be append to table
INSERT_ROWS
Insert new rows
OVERWRITE
Overwrite anything after table
Last updated