Importing Various CSV Datasource in Python

From previous post (, we learn how to deal with libraries in Python. On this post, I'm going to show you how to import CSV data using Python. I'll update this post as soon as I discover another way how to do it:

1. CSV from local computer

import pandas as pd
from google.colab import files
uploaded = files.upload()
import io
vlog96 = pd.read_csv(io.BytesIO(uploaded['vlog96.csv']))

2. CSV from GitHub

import pandas as pd
url = ''
vlog96 = pd.read_csv(url)

You can see my video below to make a practice on how to import CSV files from local computer and GitHub.

3. CSV from Google Drive (#1)

The long way:

 import pandas as pd

# Code to read csv file into Colaboratory:
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# Authenticate and create the PyDrive client.
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

link = ''
fluff, id = link.split('=')
print (id)
downloaded = drive.CreateFile({'id':id})
vlog98 = pd.read_csv('vlog98.csv')

4. CSV from Google Drive (#2)

The simple way: 

import pandas as pd

from google.colab import drive

path = '/content/drive/My Drive/data/vlog96.csv'
vlog96 = pd.read_csv(path)

I wrapped both way on a video below: 

For GitHub resource, you can use CSV from my account ( on or you can make it your own.

Labels: ,

PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address to receive feed update from this blog:

Post a Comment


Post a Comment

Leave comments here...