Skip to content

Instantly share code, notes, and snippets.

@brianspiering
Created March 9, 2021 00:10
Show Gist options
  • Save brianspiering/39a3700aae628a161e1d75af538873a4 to your computer and use it in GitHub Desktop.
Save brianspiering/39a3700aae628a161e1d75af538873a4 to your computer and use it in GitHub Desktop.
Look for local data. If not found, download it.
import pandas as pd
filename = 'loans.csv'
remote_location = 'https://raw.githubusercontent.com/DeltaAnalytics/machine_learning_for_good_data/master/'
try:
# Local version
df = pd.read_csv(filename)
except FileNotFoundError or ParserError:
# Grab the remote file and save it
url = remote_location+filename
df = pd.read_csv(url)
df.to_csv(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment