Skip to content

Instantly share code, notes, and snippets.

@john-adeojo
Created February 1, 2021 13:04
Show Gist options
  • Save john-adeojo/7ba64dfb30896b14e2f24f7711b98330 to your computer and use it in GitHub Desktop.
Save john-adeojo/7ba64dfb30896b14e2f24f7711b98330 to your computer and use it in GitHub Desktop.
Reads CSV from GitHub
# THIS FUNCTION TAKES A CSV FILE FROM A GITHUB URL AND READS IT INTO A PANDAS DATA FRAME
import pandas as pd
def read_file(url):
"""
Takes GitHub url as an argument,
pulls CSV file located @ github URL.
"""
url = url + "?raw=true"
df = pd.read_csv(url)
return df
# READ FILE FROM GITHUB REPO
# CHANGE THE URL TO YOUR DATA LOCATION!
url = "https://github.com/john-adeojo/deploy_notebook_example/blob/main/kids.csv"
kids= read_file(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment