Back

How to import a CSV from Dropbox or GitHub into Google Sheets

November 2, 2023 3 minute read
Import shipment
Source: Pexels

Introduction

Recently I really wanted to export some of my spending data from the Spending Tracker app I use in CSV format to analyse it. This app exports data to Dropbox once it's linked up. So I needed a way to bring that data into Google Sheets to analyse trends etc.

The process is quite simple once you know the steps involved, so I have documented them here! I have also documented how to do the same thing using GitHub.

As an example, we will use the Titanic dataset stored in both Dropbox and GitHub and then import that into Google Sheets from both sources 😄

First things first, we need to head across to Dropbox and copy the link to the CSV file.

This gives us the link https://www.dropbox.com/scl/fi/dm1q4w0idefrwcv1arsxf/titanic.csv?rlkey=652khaywjcazj9h0itw47b574&dl=0

For this Dropbox link we will need to change the ending from dl=0 to dl=1 so that the file is downloaded rather than viewed when we try to import it later. This is an important step.

So the correct link is https://www.dropbox.com/scl/fi/dm1q4w0idefrwcv1arsxf/titanic.csv?rlkey=652khaywjcazj9h0itw47b574&dl=1

Doing the same process for GitHub I stored the CSV within a repository named data-files. To ensure the CSV imports correctly we must first hit the 'Raw' button and copy that link instead.

This gives us the raw CSV link https://raw.githubusercontent.com/shedloadofcode/data-files/main/titanic.csv

Import CSV data from Dropbox

Now we have both links, to import that CSV data into Google Sheets, we will use the IMPORTDATA function and pass in the URL for each CSV file. Again, for the Dropbox link we will need to change the ending from dl=0 to dl=1 so that the file is downloaded.

We can enter the formula and pass the link as the first argument.

This imports the data and adds it to the current sheet.

Import CSV data from GitHub

Following the same pattern but on a new sheet, we enter the link from GitHub and hit enter.

This imports the data and adds it to the current sheet.

Analyse the data

On either sheet, if we click any cell in the table and hit Ctrl + A we can select all the data, and then go to Insert > Pivot Table and select 'New sheet'

We can then drag in fields to analyse the data. Here were are finding the count and survival rate of males vs females.

You can apply this methodology to any dataset, and any questions you have for that dataset! The best part is when the Google Sheet reloads then new data will be automatically pulled in creating a data pipeline.

Import complete!

Thanks very much for reading, this was a short article covering how to import a CSV from Dropbox or GitHub into Google Sheets.

By using this method, it creates an automated refresh when the Sheet is reloaded, ensuring analysis is always carried out on the latest data.

If you enjoyed this article be sure to check out other articles on the site. If you have any questions please leave a comment 👍 Hope this helps you out and enjoy your day!