Heike Vau
Heike Vau

Reputation: 1

Dataset uploaded and verified, but cannot use read.csv

I have uploaded a csv I created. This dataset is visible in Kaggle under "My datasets" - I can open and inspect it.

I have tried various ways of linking a dataset to my notebook.

I then ran the tidyverse and readr libraries in the Notebook, and they loaded. However, I'm getting stuck at the read.csv.

I have tried all these:

  1. df \<-read.csv("filename.csv")
  2. df \<-read.csv(https://www.kaggle.com/datasets/myname/foldername/%22filename.csv%22)

Any combination of the above, with and without " " ...

Errors I'm getting:

For 1.

Warning message in file(file, "rt"): “cannot open file 'filename.csv': No such file or directory” Error in file(file, "rt"): cannot open the connection Traceback:

  1. read.csv("filename.csv")
  2. read.table(file = file, header = header, sep = sep, quote = quote, . dec = dec, fill = fill, comment.char = comment.char, ...)
  3. file(file, "rt")

For 2.

Error in parse(text = x, srcfile = src): <text>:1:29: unexpected '/' 1: StudentDep <-read.csv(https:/ ^ Traceback:

Upvotes: 0

Views: 38

Answers (1)

rehaqds
rehaqds

Reputation: 2055

To load a dataset in a Kaggle notebook in R:

mydatapath = "/kaggle/input/datasetname/datasetfile.csv"
df <-read.csv(mydatapath)

To know exactly the dataset path (mydatapath variable), look on the right where is written "Datasets" then click on the small black triangle next to your dataset name. A list of files will appear. Click on the icon looking like a stack of papers/rectangles on the right of your csv file and use CTRL+V in your notebook to paste the file path.

Upvotes: 0

Related Questions