ETLMCPData Conveyance Works
Log in Start free
Guides

Google Sheets before the Sheets destination: CSV import and Apps Script

How to get etlmcp data into Google Sheets today: import the CSV export with Replace current sheet, or pull the REST API from Apps Script.

etlmcp's Google Sheets destination is still marked coming. Until it ships, you have two routes that work: download the pipeline's CSV export and import it with File > Import and "Replace current sheet", or write a short Apps Script that calls the REST API and writes the rows itself. Two shortcuts fail: the IMPORTDATA formula on the download link, and an Apps Script web app as a webhook receiver.

Route 1: import the CSV export

A CSV export destination writes one CSV file per run, which you download from the run page. Each file is not a slice of new days: it holds the pipeline's whole stored history, after the pipeline's transform rules.

In Sheets, open File > Import, upload the file and pick the import location:

  • Replace current sheet swaps the tab's contents for the new file. This is the option to use every time.
  • Append rows to current sheet adds the file after the last filled row. Because every export already contains all earlier days, appending repeats each of them, and your totals double with every import.
  • Insert new sheets is fine for a one-off look, but leaves you with a new tab per download.

Point your charts and pivot tables at the tab you replace, so they keep working after each import.

Size

A spreadsheet created in or converted to Google Sheets holds up to 20 million cells or 100 MB. Since the export carries full history, multiply its rows by its columns before you import. If a long history or a wide report does not fit, cut columns with transform rules, split the data by pipeline, or use a database destination such as PostgreSQL.

Why IMPORTDATA does not work

IMPORTDATA fetches a URL from Google's servers, with no etlmcp login. The export download link needs a signed-in etlmcp session; without one the request is refused. When exports are kept in cloud storage, the download link also answers with a redirect to a short-lived signed link, so even a copied signed link goes dead within minutes.

Route 2: pull the REST API from Apps Script

Apps Script's UrlFetchApp.fetch accepts a headers option, so a script bound to your spreadsheet can call Query stored data, GET /api/v1/data, with an Authorization: Bearer header carrying your etlmcp API key. Keep the key in the header: etlmcp refuses credentials passed as URL parameters such as api_key or token. Store the key in Script Properties rather than in the code.

What to expect from the response:

  • Each call returns a capped number of rows, set with limit (see Query stored data for the default and the maximum). When more rows match, the response sets truncated to true, so narrow the call with start, end, source_id or fields and make several calls.
  • The rows are the stored daily rows as pulled from each network, before any pipeline's transform rules. If you rely on renamed or computed columns, the CSV export is the closer match.
  • Write the result with one setValues call over a cleared range, which gives you the same replace-not-append behaviour as the import.

Calls count against your API rate limit of 120 requests a minute per credential.

Apps Script quotas to plan around

Google's quotas for Apps Script include:

Quota Consumer account Google Workspace
URL Fetch calls a day 20,000 100,000
Runtime per execution 6 minutes 6 minutes
Trigger runtime a day 90 minutes 6 hours
URL Fetch response size 50 MB 50 MB

A daily trigger making a handful of calls stays well inside these. A script that loops over many date ranges can hit the 6-minute limit, so fetch wider ranges with the fields you need instead.

Why an Apps Script web app cannot receive the webhook

You cannot point a webhook destination at a doPost web app. Apps Script does not answer such requests directly: a ContentService response is redirected to a one-time URL on script.googleusercontent.com, and callers have to follow that redirect. etlmcp's webhook client does not follow redirects, and it treats any redirect as a failure, so the run fails with webhook redirected. By then your doPost has already run, so rows may have been written while etlmcp records the run as failed, and the next run writes them again.

Related

Sources

  1. Import data sets & spreadsheets — support.google.com, checked
  2. Files you can store in Google Drive — support.google.com, checked
  3. Quotas for Google Services — developers.google.com, checked
  4. Class UrlFetchApp — developers.google.com, checked
  5. Content Service — developers.google.com, checked