SheetsFilteredReadDataTool()Create a tool from an API key.
Tool for reading data from Google Sheets using DataFilters.
Uses getByDataFilter API to read ranges specified by A1 notation, grid
coordinates, or developer metadata. Optionally includes detailed cell formatting.
Requires OAuth2 authentication (not API key).
This tool is for RANGE SELECTION, not conditional filtering like
'score > 50'. For conditional filtering, create a Filter View using
Sheets UI or batchUpdate API.
Tool Output:
success (bool): Whether operation succeeded. spreadsheet_id (str): The spreadsheet ID. properties (dict): Spreadsheet-level properties. sheets (list): List of sheets with filtered data containing properties and data segments.
Read using A1 notation:
from langchain_google_community.sheets import SheetsFilteredReadDataTool
tool = SheetsFilteredReadDataTool(api_resource=service)
result = tool.run(
{
"spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"data_filters": [{"a1Range": "Sheet1!A1:E10"}],
"include_grid_data": True,
}
)Read using grid coordinates:
result = tool.run(
{
"spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"data_filters": [
{
"gridRange": {
"sheetId": 0,
"startRowIndex": 0,
"endRowIndex": 10,
"startColumnIndex": 0,
"endColumnIndex": 5,
}
}
],
}
)