0

I am working on my first coding project and am wondering how to read a data file into Google Collaboratory.

I have mounted my google drive, which is where I am storing the file.

The instructions ask that we read the data as df.

I have tried running df.info('content/drive/MyDrive/OPIM 3803/Module 2/iris.data'), but am getting an error message.

I have found ways to do this with a CSV file, but this is a really old data file and it's not CSV.

Do you have any ideas on how this file should be read into google collaboratory?

Thank you for any information.

Joshua Cortigiano.

  • Does this answer your question? [How to read csv to dataframe in Google Colab](https://stackoverflow.com/questions/48340341/how-to-read-csv-to-dataframe-in-google-colab) – programandoconro Mar 04 '21 at 02:49

2 Answers2

0

It all depends on what type of file you want to read. If you want the Iris dataset for example, you just need to import it.

from sklearn import datasets
import pandas as pd
iris = datasets.load_iris()

If you want to import a local file from your computer, you can check which method you can use. Check out the pandas documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html

Also, check that you have the file in the right path. If it´s in your Colab files (when you click the folder, you would see the file there), you can click the three dots that appear next to the file when you hover and copy the path, to make sure that´s not the problem.

0

You can write the following code, and then choose your dataset from your local drive:

from google.colab import files
uploaded = files.upload()
ashkangh
  • 1,594
  • 1
  • 6
  • 9