SheetsAppendValuesTool()Create a tool from an API key.
Tool for appending values to a Google Spreadsheet table.
Inherits from
SheetsBaseTool.
Appends data to the end of a table, automatically finding the last row with data.
Requires OAuth2 authentication. Use api_resource parameter with
authenticated Google Sheets service.
Tool Output:
success (bool): Whether operation succeeded. spreadsheet_id (str): The spreadsheet ID. table_range (str): The range of the entire table. updated_range (str): The specific range where data was appended. updated_rows (int): Number of rows appended. updated_columns (int): Number of columns appended. updated_cells (int): Total number of cells updated.
Append new records to a table:
from langchain_google_community.sheets import SheetsAppendValuesTool
tool = SheetsAppendValuesTool(api_resource=service)
result = tool.run(
{
"spreadsheet_id": "1TI6vO9eGsAeXcfgEjoEYcu4RgSZCUF4vdWGLBpg9-fg",
"range": "Sheet1!A1:D100",
"values": [
["Eve", "27", "Seattle", "91"],
["Frank", "32", "Denver", "85"],
],
}
)Insert rows instead of overwriting:
result = tool.run(
{
"spreadsheet_id": "1TI6vO9eGsAeXcfgEjoEYcu4RgSZCUF4vdWGLBpg9-fg",
"range": "Sheet1!A1:D100",
"values": [["New", "Record", "Data", "Here"]],
"insert_data_option": "INSERT_ROWS",
}
)