Skip to content

How can I populate data from Google Spreadsheet? ​

Visualizer lets you populate chart data directly from a Google Spreadsheet by publishing the sheet as a CSV and importing its URL, either as a full sheet or a selective subset using Google Query Language.

In this article

Import a whole spreadsheet ​

  1. Go to your Google Drive and create a new spreadsheet document.

    New spreadsheet in Google Drive

  2. Enter your data:

    • The first line of the spreadsheet must contain the series titles.
    • The second line must contain the type of each series' data. You can use one of six data types: string, number, boolean, date, datetime, and timeofday. Enter these type names exactly as shown. Values such as time date or time of day cause the import to fail.
    • The other lines contain data values that match the chosen data type.

    Spreadsheet with series titles, data types and values

  3. Save the spreadsheet and click the File > Publish to the Web… menu item.

    Publish to the Web menu item in Google Sheets

  4. In the new dialog, click the Start publishing button. A link to the published item appears in the publishing dialog.

    Start publishing button in the publishing dialog

  5. Under the Get a link to published data subheader, choose the CSV (comma-separated values) type and copy the link to the published spreadsheet from the text area below.

    CSV link to the published spreadsheet

  6. In Visualizer, create a new chart or edit an existing one and go to the Source step. Expand the Import data from URL section, then Import from CSV / XLSX. Enter the published link into the URL field, choose an import schedule from the dropdown (select One-time for a single import), and click Import. The data is uploaded automatically and the chart preview updates.

    📝 Note: Importing data from a URL, including Google Spreadsheets, is a PRO feature. See the PRO version for details.

    Importing the published spreadsheet link in Visualizer

Use a subset of the spreadsheet ​

If your document has many columns but you only want to use some of the data, you can fetch a subset using the Google Query Language. In this example, the sheet has the following columns and you want to extract only columns A, C and E.

Example spreadsheet with several columns

  1. Click the File > Publish to the Web… menu item.

    Publish to the Web menu item in Google Sheets

  2. In the new dialog, click the Start publishing button. A link to the published item appears in the publishing dialog. Do not choose the CSV (comma-separated values) type.

    Start publishing button in the publishing dialog

  3. Now that your spreadsheet is published, Visualizer can access it once you provide the link. To get the correct link for the next steps, click the Share button in the top right:

    Share button in Google Sheets

  4. In the popup, click Copy link and save this link. It should look like this:

    https://docs.google.com/spreadsheets/d/1IcBzqIbaKoKcOsfJ0aAQMdqNmQBqvaBKzOFuTntooZs/edit?usp=sharing

  5. Using the Google Query Language, write the query that fetches the subset of data you need. In this example, the query is:

    select A,C,E

  6. Use the encoder (found on that same page) to get the correctly encoded query, and copy it.

    Google Query Language encoder

  7. Put the encoded query into this string: gviz/tq?tq=<QUERY>&tqx=out:csv

    In this example, you get: gviz/tq?tq=SELECT%20A%2CC%2CE&tqx=out:csv

  8. Put everything together to create the final link. Take the link from step 4: https://docs.google.com/spreadsheets/d/1IcBzqIbaKoKcOsfJ0aAQMdqNmQBqvaBKzOFuTntooZs/edit?usp=sharing

    Then take the query string from step 7: gviz/tq?tq=SELECT%20A%2CC%2CE&tqx=out:csv

    Remove the last part of the URL (edit?usp=sharing) and replace it with the query string. The result should look like this:

    https://docs.google.com/spreadsheets/d/1IcBzqIbaKoKcOsfJ0aAQMdqNmQBqvaBKzOFuTntooZs/gviz/tq?tq=SELECT%20A%2CC%2CE&tqx=out:csv

  9. Enter this link in Visualizer to import its data, as described in the last step of the previous section.

Use cases ​

Dynamically display form data ​

Based on the data in the Google Spreadsheet, charts can be dynamically created and updated. With Visualizer, you can display information from a form that saves data in a Google Sheet and update it in real time. When you publish the Google Sheet in CSV format, as described above, Visualizer renders the URL source and the charts update live based on users' input.

Was this helpful?