I am trying to load csv file stored in google drive to colab notebooks. When i try to load the file it is showing "File not found". What is the procedure to load files stored in google drive to colab notebooks??
Now in the Notebook, at the top-left, there is a File menu and then click on Locate in Drive, and then find your data. Then copy the path of the CSV file in a variable in your notebook, and read the file using read_csv().
Click on “Choose Files” then select and upload the file. Wait for the file to be 100% uploaded. You should see the name of the file once Colab has uploaded it. Finally, type in the following code to import it into a dataframe (make sure the filename matches the name of the uploaded file).
You can either use the upload option at the top of the file-explorer pane to upload any file(s) from your local file system to Colab in the present working directory. 2. Select the “upload” option.
easiest way I found is mounting google drive in colab:
from google.colab import drive
drive.mount('/content/gdrive')
then use '/content/gdrive/My Drive/' as prefix of the file path. suppose you have a text file in data directory of you google drive. Then you can access it with following code:
open('/content/gdrive/My Drive/data/filename.txt').read()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With