colab python with open file code example
Example 1: colab read file
from google.colab import files
import io
uploaded = files.upload()
df2 = pd.read_csv('Filename.csv')# Dataset is now stored in a Pandas Dataframe
Example 2: colab import python file
# In case anyone else is interested to know how to import files/packages
# from gdrive inside a google colab. The following procedure worked for
# me:
# 1) Mount your google drive in google colab:
from google.colab import drive
drive.mount('/content/gdrive/')
# 2) Append the directory to your python path using sys:
import sys
sys.path.append('/content/gdrive/mypythondirectory')
# Now you should be able to import stuff from that directory!