🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

gspread-sheets

by @nuokunkeji

Batch read/write Google Sheets using the gspread Python library with service account authentication. Use when the user needs to: (1) read/write/update/clear...

Versionv1.0.0
πŸ’‘ Examples

Initialize Client

import gspread
from google.oauth2.service_account import Credentials

SCOPES = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']

Option 1: From JSON file path

creds = Credentials.from_service_account_file('key.json', scopes=SCOPES) gc = gspread.authorize(creds)

Option 2: From JSON string (e.g. env var)

import json, os creds_info = json.loads(os.environ['GOOGLE_SERVICE_ACCOUNT_JSON']) creds = Credentials.from_service_account_info(creds_info, scopes=SCOPES) gc = gspread.authorize(creds)

Open Spreadsheet

# By name
sh = gc.open("My Spreadsheet")

By URL

sh = gc.open_by_url("https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit")

By key

sh = gc.open_by_key("SPREADSHEET_ID")

βš™οΈ Configuration

pip install gspread google-auth

Service account JSON key file required. Set path via:

  • Environment variable: export GOOGLE_SERVICE_ACCOUNT_JSON=/path/to/key.json
  • Or pass explicitly in scripts
  • Share the target spreadsheet with the service account email (found in the JSON key file).

    πŸ“‹ Tips & Best Practices

  • Use batch_update over multiple update calls β€” fewer API requests
  • value_input_option="USER_ENTERED" parses formulas and number formats
  • value_input_option="RAW" writes literal strings
  • Default include_empty=False in get_all_values omits trailing empty cells
  • Service account has its own Drive; share sheets with its email to access
  • For shared drives, use gc.open_by_key() (more reliable than name)
  • View on ClawHub
    TERMINAL
    clawhub install gspread-sheets

    πŸ§ͺ Use this skill with your agent

    Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

    πŸ” Can't find the right skill?

    Search 60,000+ AI agent skills β€” free, no login needed.

    Search Skills β†’