NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
The ObjImportApi class in ObjDataImportGsheets.py imports data from Google
Sheets using the gspread library with service account authentication. It
follows the same open_file / column_list / next_row / close_file
interface used by all other ObjDataImport* modules.
All cell values are returned as strings. The entire worksheet is read into
memory on open_file.
prep_file(filename) -> strNo-op — returns the filename unchanged.
open_file(filename)Opens a Google Sheet by URL or spreadsheet ID. The filename parameter is
either a full Google Sheets URL or the spreadsheet key.
Worksheet selection:
self.parent._Sourcetable if set (the sheet name to read).Credentials: The service account JSON file path is resolved from:
config.yaml key google.service_account_file.data.config/google_service_account.json.The first row is treated as column headers.
close_file()Releases the in-memory record list.
column_list() -> listReturns the column names from the first row (headers).
next_row() -> list | strReturns the next record as a list of string values in column order. Missing
keys are returned as "". Returns "EOF" when all records have been read.
importer = ObjImportApi()
importer.open_file(
"https://docs.google.com/spreadsheets/d/SHEET_ID/edit"
)
columns = importer.column_list()
print("Columns:", columns)
while True:
row = importer.next_row()
if row == "EOF":
break
print(dict(zip(columns, row)))
importer.close_file()
Add the service account credentials path to config.yaml:
google:
service_account_file: data.config/my_service_account.json
Requires the gspread package:
pip install gspread
The Google Sheet must be shared with the service account email address.
Updated: 2026-03-22