space in directory name

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

space in directory name

dbonneau
Hi, I am trying to read a text file located in following paths. I am getting error if I try to read from long directory..  But if I place the file right under C, It runs fine. Could anyone tell me how to read table from following directory path ?

data1 <-read.table("C:\\Documents and Settings Administrator\\My Documents\\My Dropbox\\data.txt", sep="\t", header=TRUE)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:\Documents and Settings Administrator\My Documents\My Dropbox\data.txt': No such file or directory
> data1 <-read.table("C:\\data.txt",sep="\t",header=TRUE)
>
Reply | Threaded
Open this post in threaded view
|

Re: space in directory name

Mikkel Grum
You are missing \\ between Documents and settings and Administrator.


----- Original Message -----
From: dbonneau <[hidden email]>
To: [hidden email]
Cc:
Sent: Tuesday, September 13, 2011 10:59 AM
Subject: [R] space in directory name

Hi, I am trying to read a text file located in following paths. I am getting
error if I try to read from long directory..  But if I place the file right
under C, It runs fine. Could anyone tell me how to read table from following
directory path ?

data1 <-read.table("C:\\Documents and Settings Administrator\\My
Documents\\My Dropbox\\data.txt", sep="\t", header=TRUE)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:\Documents and Settings Administrator\My Documents\My
Dropbox\data.txt': No such file or directory
> data1 <-read.table("C:\\data.txt",sep="\t",header=TRUE)
>

--
View this message in context: http://r.789695.n4.nabble.com/space-in-directory-name-tp3810448p3810448.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: space in directory name

Jean-Christophe BOUËTTÉ
In reply to this post by dbonneau
I suggest changing
Documents and Settings Administrator
to
Documents and Settings\\Administrator

...
JC

2011/9/13 dbonneau <[hidden email]>:

> Hi, I am trying to read a text file located in following paths. I am getting
> error if I try to read from long directory..  But if I place the file right
> under C, It runs fine. Could anyone tell me how to read table from following
> directory path ?
>
> data1 <-read.table("C:\\Documents and Settings Administrator\\My
> Documents\\My Dropbox\\data.txt", sep="\t", header=TRUE)
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>  cannot open file 'C:\Documents and Settings Administrator\My Documents\My
> Dropbox\data.txt': No such file or directory
>> data1 <-read.table("C:\\data.txt",sep="\t",header=TRUE)
>>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/space-in-directory-name-tp3810448p3810448.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: space in directory name

bbolker
Jean-Christophe BOUËTTÉ <jcbouette <at> gmail.com> writes:

>
> I suggest changing
> Documents and Settings Administrator
> to
> Documents and Settings\\Administrator
>

  Please don't cross-post to R-help and Stack Overflow.
People in both places will gladly answer well-posed questions,
but it turns into a waste of effort to have people answering in both places.
It's your choice which venue you prefer.

  Ben Bolker

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: space in directory name

Henrik Bengtsson-3
In reply to this post by Jean-Christophe BOUËTTÉ
FYI,

by using

library("R.utils");
pathname <- "C:\\Documents and Settings Administrator\\My
Documents\\My Dropbox\\data.txt";
pathname <- Arguments$getReadablePathname(pathname);
data1 <- read.table(pathname, sep="\t", header=TRUE);

you would get an explanation what is wrong and helps you troubleshoot, e.g.

Error in list(`Arguments$getReadablePathname(pathname)` = <environment>,  :
[2011-09-13 12:25:35] Exception: Pathname not found: C:/Documents and
Settings Administrator/My Documents/My Dropbox/data.txt (none of the
parent directories [C:/Documents and Settings Administrator/My
Documents/My Dropbox/] exist)

Another example:

pathname <- "C:\\Users\\All Users\\Documents\\NonExistingDir\\data.txt";
pathname <- Arguments$getReadablePathname(pathname);

Error in list(`Arguments$getReadablePathname(pathname)` = <environment>,  :
[2011-09-13 12:30:29] Exception: Pathname not found: C:/Users/All
Users/Documents/NonExistingDir/data.txt (C:/Users/All Users/Documents/
exists, but nothing beyond)

/Henrik

On Tue, Sep 13, 2011 at 10:37 AM, Jean-Christophe BOUËTTÉ
<[hidden email]> wrote:

> I suggest changing
> Documents and Settings Administrator
> to
> Documents and Settings\\Administrator
>
> ...
> JC
>
> 2011/9/13 dbonneau <[hidden email]>:
>> Hi, I am trying to read a text file located in following paths. I am getting
>> error if I try to read from long directory..  But if I place the file right
>> under C, It runs fine. Could anyone tell me how to read table from following
>> directory path ?
>>
>> data1 <-read.table("C:\\Documents and Settings Administrator\\My
>> Documents\\My Dropbox\\data.txt", sep="\t", header=TRUE)
>> Error in file(file, "rt") : cannot open the connection
>> In addition: Warning message:
>> In file(file, "rt") :
>>  cannot open file 'C:\Documents and Settings Administrator\My Documents\My
>> Dropbox\data.txt': No such file or directory
>>> data1 <-read.table("C:\\data.txt",sep="\t",header=TRUE)
>>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/space-in-directory-name-tp3810448p3810448.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: space in directory name

Jean-Christophe BOUËTTÉ
In reply to this post by Mikkel Grum
And a final word of advice: be lazy, and use
file.choose()
to get the string that R expects as a filename. This will help avoid such typos!

JC

2011/9/13 Mikkel Grum <[hidden email]>:

> You are missing \\ between Documents and settings and Administrator.
>
>
> ----- Original Message -----
> From: dbonneau <[hidden email]>
> To: [hidden email]
> Cc:
> Sent: Tuesday, September 13, 2011 10:59 AM
> Subject: [R] space in directory name
>
> Hi, I am trying to read a text file located in following paths. I am getting
> error if I try to read from long directory..  But if I place the file right
> under C, It runs fine. Could anyone tell me how to read table from following
> directory path ?
>
> data1 <-read.table("C:\\Documents and Settings Administrator\\My
> Documents\\My Dropbox\\data.txt", sep="\t", header=TRUE)
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>   cannot open file 'C:\Documents and Settings Administrator\My Documents\My
> Dropbox\data.txt': No such file or directory
>> data1 <-read.table("C:\\data.txt",sep="\t",header=TRUE)
>>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/space-in-directory-name-tp3810448p3810448.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.