• Register
0 votes

Problem :

I am very new to the R, and after researching my error as below extensively, I am still unable to find the fix for it. I have already checked my working directory, and also made sure that the files are in a correct directory.

Error in file(file, "rt") : cannot open the connection file(file, "rt") read.table(file = file, header = header, sep = sep, quote = quote,dec = dec, fill = fill, comment.char = comment.char, ...)
read.csv(specdatapaths[i], header = T, sep = ",")pollutantmean3("specdata", "sulfate", 1:10)
In addition: Warning message:
In file(file, "rt") : cannot open file './specdata001.csv': No such file or directory


6 5 3
7,540 points

1 Answer

0 votes

Solution :

I had spent a lot of time in recent past trying to understand what was actually wrong with my code.

And it seems to be very simple if you are using windows.

When you name the file "xyz.txt" then your windows name it as "xyz.txt.txt"... That will be the same with .CSV files as well so windows create the file named "007.csv.csv" if you called it "007.csv"

So, whenever you try to create your .csv file, you just rename it as"007" and open it in the R using below command :


 It will work for you as it works for me.

9 7 4
38,600 points

Related questions

0 votes
2 answers 845 views
Problem : I have the RScript file (let's call it main.r) which has the reference to another file, using the following code: source("functions.R") But, when i run a RScript file, it complains with the following error: Error in file(filename, "r", encoding = encoding) ... next to the functions.R in a same directory. I can call a functions.R in a RMd (RMarkdown) file which exist in a same directory
asked Jan 17 jwilliam 3.9k points
1 vote
2 answers 440 views
Problem : I am getting following error while trying to read the CSV file with R. in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : eof within quoted string
asked Nov 11, 2019 peterlaw 6.9k points
0 votes
1 answer 1.3K views
Problem : MySample.csv contains the below details : NAME Id No Dept Tommy 1 12 CS Jimmy 2 35 EC Bonny 3 21 IT Franky 4 61 EE And my Python file contains the below code : import csv myifile = open('mysample.csv', "rb") read = csv.reader(myifile) for row in read : ... in for row in read : _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?) How should I fix it?
asked Jan 2 alecxe 7.5k points
0 votes
1 answer 795 views
Problem : When I run my Python code I get the following exception: _csv.error: iterator should return strings, not bytes (did you open the file in text mode?)
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
1 answer 349 views
Probem : I am getting bellow error new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
asked Nov 7, 2019 peterlaw 6.9k points