| name | google_sheets |
| description | Read and update Google Sheets spreadsheets via Python |
Google Sheets Skill
Read and update Google Sheets using Python's gspread library (pre-installed in container).
Credentials
Credentials are pre-configured at /root/.google/credentials.json. No manual setup needed.
Connect
import json
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
import gspread
with open("/root/.google/credentials.json") as f:
cred_data = json.load(f)
creds = Credentials(
token=cred_data.get("token"),
refresh_token=cred_data["refresh_token"],
token_uri=cred_data["token_uri"],
client_id=cred_data["client_id"],
client_secret=cred_data["client_secret"],
)
creds.refresh(Request())
gc = gspread.authorize(creds)
Open a Spreadsheet
sheet = gc.open("Q1_Content_Budget")
sheet = gc.open_by_url("https://docs.google.com/spreadsheets/d/SHEET_ID/edit")
ws = sheet.sheet1
Read Data
all_data = ws.get_all_values()
all_records = ws.get_all_records()
val = ws.acell("B2").value
vals = ws.get("A1:D4")
Write Data
ws.update_acell("B2", "new value")
ws.update("A1:C2", [
["Name", "Status", "Amount"],
["Campaign A", "Active", "5000"],
])
ws.append_row(["Campaign B", "Pending", "3000"])
Find Cells
cell = ws.find("Campaign A")
print(f"Found at row {cell.row}, col {cell.col}")
cells = ws.findall("Active")
Spreadsheet name and other task-specific details will be provided in the task context.