Alice
Alice

Reputation: 57

Opening csv file in Jupyter Notebok using R

I am trying to open a dataset saved as a csv on Jupyter Notebook. I saved the dataset on my desktop:

data <- read.csv("⁨⁨Desktop/dataset1.csv")

I am getting the following error:

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

  1. read.csv("\u2068/Desktop\u2069/dataset1.csv")
  2. read.table(file = file, header = header, sep = sep, quote = quote, . dec = dec, fill = fill, comment.char = comment.char, ...)
  3. file(file, "rt")

Can anyone understands what is going on? I am learning how to use Jupyter Notebook and I cannot find an answer online.

Upvotes: 0

Views: 5491

Answers (2)

Andrew Chisholm
Andrew Chisholm

Reputation: 6567

Upload the file as in the red highlight in this screenshot. The uploaded file will then be local to any notebooks created in the same folder.

enter image description here

So your code would be

read.csv("yourfile.csv")

Upvotes: 0

GMfatcat
GMfatcat

Reputation: 11

There's another way to read file using relative path:

setwd() : set working directory

getwd() : get working directory

if you put your file in desktop,it will be like this:

    setwd("C:/User/user/dektop") 
    a <- read.csv("filename.csv")

Upvotes: 0

Related Questions