0

I have a ipython file that I want to execute on colab. When I first ran it, the local files were imported but now it gives me an error.Following are the code snippet and error

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-1-9132fbd19d75> in <module>()
      1 import pickle
----> 2 pickle_in = 
open(r"C:/Users/manas/PycharmProjects/allProjects/X.pickle","rb")
      3 X = pickle.load(pickle_in)
      4 
      5 pickle_in = 
open(r"C:/Users/manas/PycharmProjects/allProjects/y.pickle","rb")

FileNotFoundError: [Errno 2] No such file or directory: 
'C:/Users/manas/PycharmProjects/allProjects/X.pickle'



import pickle
pickle_in = 
open(r"C:/Users/manas/PycharmProjects/allProjects/X.pickle","rb")
X = pickle.load(pickle_in)

pickle_in = 
open(r"C:/Users/manas/PycharmProjects/allProjects/y.pickle","rb")
Y = pickle.load(pickle_in)
Manas Bam
  • 59
  • 1
  • 6
  • import your file using the menu in the left panel `files/upload`. [this](https://stackoverflow.com/questions/46986398/import-data-into-google-colaboratory) can be helpful – scraaappy Sep 22 '18 at 13:47

1 Answers1

0

You can upload your files on colab if you're not going to be doing this often. Else it can get quite annoying.

from google.colab import files
files.upload()

Using the above snippet you can upload and use whatever you'd like.

However, if you're pickles are of a larger size, I'd advice you to just upload them on your Drive. Accessing them from your Drive is far easier and less troublesome. To access files on your Drive, all you have to do is mount it in colab's file directory.

from google.colab import drive
drive.mount("/content/drive")

This will generate a link, click on it and sign in using Google OAuth, paste the key in the colab cell and you're connected.

Check out the list of available files in the side panel on the left side and copy the path of the file you want to access. Read it as you would, with any other file.

gavin
  • 793
  • 1
  • 7
  • 19