Comment on page
Export Airtable to Google Sheets
Update a Google Sheet with Airtable data on a schedule
Google sheets allows you to easily create automations in your Google Sheet using Google App Script. We are going to use it to create a function that will update your GSheet with your latest Airtable data. The great thing about this function is that it can be scheduled to run at an interval of your choosing.
Open your Google sheet and click 'Extentions'.

Under Extensions, click App Script.

In your Code.gs file, paste the following code
function csvGetter() {
// URL of the CSV file [REPLACE WITH YOURS]
var url = "https://api.csvgetter.com/g2GikbXnBuK52oCeNhWf";
// Fetch the CSV file
var response = UrlFetchApp.fetch(url);
// Get the contents of the file as a string
var csvString = response.getContentText();
// Convert the CSV string to a 2D array
var csvData = Utilities.parseCsv(csvString);
// Get the active sheet
var sheet = SpreadsheetApp.getActiveSheet();
// Clear the existing data in the sheet
sheet.clear();
// Write the data from the CSV file to the sheet
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}

Saving the Code.gs file, you can now run the function called
csvGetter
. (You may need to give this script permission to access the sheet. I explain this in the video above.)
Once you have run the function ... Congratulations! - your gsheet will now be full of your Airtable data.
🎉

Now lets setup a schedule. Back in the Apps Script screen, click Triggers (the alarm clock icon)

Click Add Trigger

Under trigger settings, click 'Time Driven' - this allows you to customise how often the trigger is run.

These settings will mean that the google sheet will update every hour
Once you press save, your Trigger is live . You can see its working by waiting for a 'Last Run' timestamp to appear.
🎉

And now your Google Sheet is updating automatically from Airtable.
Add
?email_me=true
to the end of your URL to recieve an email notification of your scheduled backup. You can even add a label by appending &email_tag=<your_tag>
. Check out the example:
In this example, I'd like my email to show me I have backed up Airtable with google sheets

With email_me set to true, you will get an email like this (limited 1 per day)
function csvGetter() {
var sheetInfo = [
{ url: "https://api.csvgetter.com/U5ZjTjsVOzIqSC1aN3OX", sheetName: "Sheet1" },
{ url: "https://api.csvgetter.com/g2GikbXnBuK52oCeNhWf", sheetName: "Sheet2" },
// add more if needed
];
// Loop through the array and update each sheet
for (var i = 0; i < sheetInfo.length; i++) {
var info = sheetInfo[i];
updateSheetFromCSV(info.url, info.sheetName);
}
}
function updateSheetFromCSV(url, sheetName) {
var response = UrlFetchApp.fetch(url);
var csvString = response.getContentText();
var csvData = Utilities.parseCsv(csvString);
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName(sheetName);
if (!sheet) {
sheet = spreadsheet.insertSheet(sheetName);
} else {
sheet.clear();
}
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
Last modified 1mo ago