Pandas: Read CSV from Github

Step 1: Hit “Raw” button

You go to the Github page and find the csv file page. For instance, you can click this link for one. Then, you click Raw.

Python Pandas: Read CSV from Github step 1
Python Pandas: Read CSV from Github step 1

Step 2: Copy the raw link and paste into the read_csv()

Next, you copy the link and paste it within the function of read_csv() from Pandas.

Python Pandas: Read CSV from Github step 2
Python Pandas: Read CSV from Github step 2
import pandas as pd
df=pd.read_csv("https://raw.githubusercontent.com/TidyPython/Pandas_read_save_files/main/car_data.csv")
print(df)
   Unnamed: 0  Brand Location  Year    DateTime
0           0  Tesla       CA  2019  2019-03-10
1           1  Tesla       CA  2018  2018-03-11
2           2  Tesla       NY  2020  2020-01-01
3           3   Ford       MA  2019  2019-03-24

Finally, as you see, the print out shows that we successfully read the CSV file from Github.


Further Reading

Upload CSV to Github

How to read CSV or Excel files in Pandas

How to read Excel files with multiple sheets with Pandas

Pandas: Read all sheets in Excel