import library in colaboratory code example

Example: how to import custom libraries in colab

#NOTE:- FILE NAMES ARE ALWAYS CASE SENSITIVE
##In colab cell,insert the following code..

from google.colab import files
uploaded = files.upload()
for file in uploaded:
  print("file name : {} , length: {}".format(file,len(file)))
  
##after you run the cell simply select the file you want to upload
#after you have selected the correct file you will see the following:
'''
chosen_file_name.py(text/x-python) - 1842 bytes, last modified: 09/06/2020 - 100% done
Saving chosen_file_name.py to chosen_file_name.py
file name : chosen_file_name.py , length:(the length of file)
'''
#Now simply write in the cell 
import chosen_file_name
#You are now done :)

Tags:

Misc Example