Skip to main content
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

The credentials= 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.
Default scopes are read-only for enrich_from_sheet / resolve_from_sheet / read_sheet, and read-write for write_sheet / to_sheet. If you pass a pre-built gspread.Client or Credentials, the SDK uses the scopes you configured — bring your own if you need something different.

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:
Columns not in the mapping pass through unchanged. Empty cells are dropped so pydantic-Optional fields stay None.

Range and tab

Omit sheet_name to use the first tab. Omit range_ to read the whole worksheet.

Chunking

The Data API caps enrich 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.
If the workbook has more than one sheet, sheet_name= is required (we don’t pick for you):
Raw row access works the same way:

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:
  1. Create a project in Google Cloud Console.
  2. Enable the Google Sheets API for that project.
  3. Create a service account, download its JSON key.
  4. 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.
  5. Point credentials= at the JSON path, or set GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.json in your environment.
Service accounts are usually the right call for server-side / scheduled runs. For interactive / notebook use where you’d prefer to log in as yourself, build a gspread.Client with OAuth and pass it to credentials=.