Python helpers

read_google_sheets_range

Read any rectangle of Google Sheet cells by position, with formulas, notes and links.

Requires Viewer access for Octocom's Google account and a connected spreadsheet. See Google Sheets setup.

read_google_sheets_range(sheet_id: str, range: str, sheet_name: str = None) -> dict

Reads a range of cells by position, without treating any row as headers. Use it for sheets that aren't simple tables, such as a price grid or a form-like layout. Supply a bounded tab-local A1 range of at most 10,000 cells within the current grid. Every call reads fresh data.

The result has sheetId, sheetName, range, one-based startRow and startColumn, rectangular rows of cell objects, rowMetadata and columnMetadata, and intersecting merges. Row and column metadata are described below. Cells have displayText, hyperlinks, and an optional formula or note. Blank positions are preserved. Merges use zero-based, end-exclusive indices, and their values are not expanded.

Hidden rows and columns

Hidden rows and columns are included by default. Two keyword-only options leave them out:

OptionDefaultEffect
include_hidden_rowsTrueSet to False to skip rows hidden by a person or by a sheet filter
include_hidden_columnsTrueSet to False to skip columns hidden by a person or by a sheet filter

The response's rowMetadata and columnMetadata line up with the returned rows and columns. Each entry has index (the original one-based row or column number), hiddenByUser, hiddenByFilter and hidden. range, startRow, startColumn and merges keep their original coordinates even when hidden rows or columns are left out. Personal filter views are not evaluated.

Example

page = read_google_sheets_range("SHEET_ID", "B2:D100", sheet_name="October")
for row in page["rows"]:
    print(row[0]["displayText"], row[1]["hyperlinks"])

See Google Sheets helpers for access, limits, merged cells, cache freshness and safe recovery after failures.

On this page