From the course: Complete Guide to Analytics Engineering

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Data fetching

Data fetching

- [Instructor] We've built our first data pipeline, now let's build another where we fetch data from an external dataset using a URL-based direct file export. We're going to take some data into a Google Sheet and create a function that will fetch the data and bring it into a data frame. The URL for this Google Sheet is found in the GoogleSheetURL.txt file in our file explorer. Let's open that now. If you follow that URL, you'll see the data we're trying to bring into our database. You can open that URL by holding control and clicking on it or copying and pasting it into your browser. Here you can see a Google Sheet with state_name, state_code, and state_timezone, and all 50 United States. Let's go back to GitHub Codespaces and create a new Python script called Datafetch.ipynb. In a new cell, let's import pandas. We'll define a new variable called get_data_from_google_sheet. We'll reference sheet_url. Define csv_url. We use replace to clean up the URL a little bit. Now we use try. If…

Contents