0

How to import the dataset I have already uploaded, to my Google Collab Juypter notebook?

I have successufully uploaded my data using: google.colab.files method

uploaded = files.upload()

But when I try to read the uploaded data(Here train.csv) , it throws FileNotFound error

df = pd.read_csv('train.csv')

Maybe the files by default are getting stored in some other directory. Any sugesstions on how do I import my data? Thanks for help!

Nikhil Mishra
  • 1,182
  • 2
  • 18
  • 34
  • Please take a look at [Local file system](https://colab.research.google.com/notebook#fileId=/v2/external/notebooks/io.ipynb&scrollTo=eikfzi8ZT_rW). – srikavineehari Jan 22 '18 at 17:02
  • @srig It just mentions how to upload and download a file. I have already uploaded the file sucessfully using : Uploading files from your local file system. What I want is to import my uploaded file into my code – Nikhil Mishra Jan 22 '18 at 17:14
  • Issue resolved thank you – Nikhil Mishra Jan 22 '18 at 18:04
  • Can I import files already in my google drive. I don't want to upload files from the local system but from files already in the cloud or google drive – Nikhil Mishra Jan 22 '18 at 18:12

1 Answers1

0

I believe the issue is identical to this answered question -- read csv to dataframe in google colab

The file data is in uploaded['train.csv'], which you'll want to wrap in a StringIO.

Bob Smith
  • 36,107
  • 11
  • 98
  • 91