Search code examples
rgoogle-colaboratory

Loading CSV File in Google Colaboratory


HI I am using Jyputer Notebook Colaboratory

I am writing in R

How can I load the CSV File as r code

Regards


Solution

  • I am not familiar with R, but the instructions should be relatively similar to Python.

    This article is very useful: https://towardsdatascience.com/3-ways-to-load-csv-files-into-colab-7c14fcbdcb92

    If none of the methods in the article suit your needs, here is another method that involves mounting your Google Drive to Collaboratory:

    1. Go to Google Colab and type:

    from google.colab import drive drive.mount('/content/gdrive')

    1. Run the code block (Ctrl + Enter), click on the link, sign in to your Google account, and copy the authorization code and paste it into the output of the code block in Google Colab.
    2. The files in your Google Drive should be under the 'Files' tab when you open the left toolbar (by clicking the small arrow on the left side of the screen).
    3. When you want to load the CSV in your code, enter this line of code (where loadCSV is the variable name, and the part after the = sign is the directory of the file):

    loadCSV = "gdrive/My Drive/dataset.csv"