mc.io lets you point the SDK at a spreadsheet, run the Data API on its
rows, and write the results back — without the manual “read CSV → build
records → call API → flatten response” loop.
Two formats today: Google Sheets (via gspread) and Excel .xlsx
(via openpyxl). Each is gated on its own optional extra so the base wheel
stays small.
Google Sheets
Read + run + write
resolve_from_sheet works the same way and returns a ResolveResponse.
Credentials
Thecredentials= kwarg accepts whatever’s most natural for your
environment — the SDK figures out what shape you passed:
The env-var fallback matches Google’s own conventions, so apps already
running with that variable set need no extra config.
Field mapping
By default the first row is the header, and each column name maps 1:1 to an enrich field (record_id, linkedin_url, first_name,
emails, …). If your sheet has different column names, rename via
field_mapping:
None.
Range and tab
sheet_name to use the first tab. Omit range_ to read the whole
worksheet.
Chunking
The Data API capsenrich and resolve at 500 records per call. mc.io
chunks transparently — pass a 2,000-row sheet, the SDK runs four batches
and returns one merged EnrichResponse (the api_request_id field
reflects the last batch).
Lower-level read/write
If you need just the rows (not the API call), use the raw helpers:Excel (.xlsx)
Same shape as Sheets, but reads from a local file path — no auth required.sheet_name= is required (we
don’t pick for you):
Writing any response to a sheet
to_sheet() and to_excel() live on every typed response — EnrichResponse,
ResolveResponse, UsageResponse, etc. The response is flattened the same
way to_csv() flattens it (union of keys across all rows, missing cells
left blank):
Errors
Setting up a Google service account (one-time)
If you don’t have one yet:- Create a project in Google Cloud Console.
- Enable the Google Sheets API for that project.
- Create a service account, download its JSON key.
- Share the target sheet with the service account’s email address
(it looks like
name@project.iam.gserviceaccount.com). Without this step the service account can’t see the sheet, even with valid creds. - Point
credentials=at the JSON path, or setGOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.jsonin your environment.
gspread.Client with OAuth and pass it to
credentials=.