Feeling stuck with Segment? Say 👋 to RudderStack.

SVG
Log in

How to load data from Google Sheets to Google BigQuery

Access your data on Google Sheets

The first step in loading your Google Sheets data to any kind of data warehouse solution is to access your data and start extracting it.

Google Sheets offers a REST API that can be used to programmatically interact with your account. Due to the nature of the application, there is no specific set of tables that are being extracted but instead each sheet of each spreadsheet is represented as a separate table.

In addition to the above, the things that you have to keep in mind when dealing with the Google Sheets API, are:

  1. Rate limits. Depending on the API version that is being used, Google Sheets API has rate limits per project and per user.
  2. Authentication. You authenticate on Google Sheets using either OAuth or the application’s API key.
  3. Paging and dealing with a big amount of data. Platforms like Google Sheets that are dealing with clickstream data tend to generate a lot of data, like events on your web properties.
[@portabletext/react] Unknown block type "aboutNodeBlock", specify a component for it in the `components.types` prop

Transform and prepare your Google Sheets Data for Google BigQuery Replication

After you have accessed your data on Google Sheets, you will have to transform it based on two main factors,

  1. The limitations of the database that the data will be loaded onto
  2. The type of analysis that you plan to perform

Each system has specific limitations on the data types and data structures that it supports. If for example, you want to push data into Google BigQuery, then you can send nested data like JSON directly, but keep in mind that the data you get from Google Sheets are in the form of a tabular report just like a CSV.

Of course, when you are dealing with tabular data stores, like Microsoft SQL Server, this is not an option. Instead, you will have to flatten out your data, just as in the case of JSON, before loading into the database.

Also, you have to choose the right data types. Again, depending on the system that you will send the data to and the data types that the API exposes to you, you will have to make the right choices. These choices are important because they can limit the expressivity of your queries and limit your analysts on what they can do directly out of the database. Google Sheets has a very limited set of available data types which means that your work to do these mappings is much easier and straightforward, but nonetheless equally important with any other case of a data source.

Due to the rich and complex data model that Google Sheets follows, some of the provided resources might have to be flattened out and be pushed in more than one table.

Import your Google Sheets from Google Drive. Load them to PostgreSQL to run custom SQL queries and to generate custom reports and dashboards. Combine your Google Sheets data with other data sources to make it even more valuable.

..you can easily integrate, connect, and watch your Google Sheets data flow into PostgreSQL.

Google Sheets is an online spreadsheet app that lets users create and format spreadsheets while simultaneously working with other people. Businesses can use Google Sheets to maintain data consistency across departments and to ensure that every member of their team is on the same page

Read, write, and format data in Sheets. Programmatically create and update pivot tables, data validation, charts, and more.

Export data from Google Sheets to BigQuery

If you want to load Google Sheets data to Google BigQuery, you have to use one of the following supported data sources.

  1. Google Cloud Storage
  2. Sent data directly to BigQuery with a POST request
  3. Google Cloud Datastore Backup
  4. Streaming insert
  5. App Engine log files
  6. Cloud Storage logs

From the above list of sources, 5 and 6 are not applicable in our case.

For Google Cloud Storage, you first have to load your data into it, there are a few options on how to do this, for example, you can use the console directly as it is described here and do not forget to follow the best practices.

Another option is to post your data through the JSON API, as we see again APIs play an important role in both the extraction but also the loading of data into our data warehouse. In its simplest case, it’s just a matter of one HTTP POST request using a tool like CURL or Postman.

After you have loaded your data into Google Cloud Storage, you have to create a Load Job for BigQuery to actually load the data into it, this Job should point to the source data in Cloud Storage that have to be imported, this happens by providing source URIs that point to the appropriate objects.

The best way to load data from Google Sheets to Google BigQuery

So far we just scraped the surface of what can be done with Google BigQuery and how to ingest data into it. The way to proceed relies heavily on the data you want to load, from which service they are coming from, and the requirements of your use case. Things can get even more complicated if you want to integrate data coming from different sources.

A possible alternative, instead of writing, hosting, and maintaining a flexible data infrastructure, is to use a product like RudderStack that can handle this kind of problem automatically for you.

Easily use the Google Sheets connector from RudderStack, along with multiple sources or services like databases, CRM, email campaigns, analytics, and more.

Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.

Don't want to go through the pain of direct integration?

RudderStack's Google Sheets integration

makes it easy to send data from Google Sheets to Google BigQuery.