Re: [R] Cannot read in a csv file.

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Sat, 07 May 2011 16:14:15 -0700 (PDT)

> From: Duncan Murdoch <murdoch.duncan_at_gmail.com>
> Subject: Re: [R] Cannot read in a csv file.
> To: "John Kane" <jrkrideau_at_yahoo.ca>
> Cc: r-help_at_r-project.org
> Received: Saturday, May 7, 2011, 4:20 PM
> On 11-05-07 1:26 PM, John Kane
> wrote:
> > Can anyone suggest why this file  http://www.mediafire.com/?afeyhhpacaq
> > is refusing to open for me.?
> >
> > I must admit I don't know all its history but the
> original data was taken from an OOo spreadsheet that I
> edited (good bit of copying and pasting and the month
> variable added by hand in OOo Calc) and, then,saved as a csv
> file.  It was not originally an English language file
> as far as I can determine.  It may have been created in
> Excel for all I know.
> >
> > If I load the file into my text editor (Tinn-r) I can
> read the material in using the textConnection command and
> have no problem working with it.  However this meant
> that I spend an hour and a half trying to read the file and
> 5 minutes doing the graph I wanted.  I'd like to avoid
> my mistake in the future if possible.
> >
> > I'm showing my last try below but the directory is
> almost certainly correct. I've tried it  using a full
> path name and, as below, after changing the active
> directory.
> >
> > When I try to load the file  I get this:
> >
> >> read.csv("asp.csv", header=TRUE, sep=",")
> >
> > Error in file(file, "rt") : cannot open the
> connection
> > In addition: Warning message:
> > In file(file, "rt") : cannot open file 'asp.csv': No
> such file or directory
> >
>
> If the filename is really correct, then it would appear to
> be a
> permissions problem.  Do you have read permission on
> that file?  Try
> opening it in Notepad or some other program.
No problem with permissions

>
> If that works, then I'd suggest that you actually don't
> have the
> filename correct.  (Windows does dumb things like
> displaying the file
> "asp.csv.txt" as "asp.csv" by default.)  If you use
> the file.choose()
> function to select the file, you'll get the right
> filename.
That's it. Somehow I managed to introduce an extra . in the file name and somehow never noticed it.

file.choose() gave
"C:\\rdata\\asp..csv"

Must be the new glasses. If I take them off and peer at the screen from about 3 inches I can see the extra dot!

Thanks very much.
> Duncan Murdoch
>
> > sessionInfo()
> >
> > R version 2.12.2 (2011-02-25)
> > Platform: i386-pc-mingw32/i386 (32-bit)
> >
> > locale:
> > [1] LC_COLLATE=English_Canada.1252 
> LC_CTYPE=English_Canada.1252
> > [3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
> > [5] LC_TIME=English_Canada.1252
> >
> > attached base packages:
> > [1] grid      stats 
>    graphics  grDevices utils 
>    datasets 
> methods   base
> >
> > other attached packages:
> > [1] ggplot2_0.8.9 proto_0.3-9.1 reshape_0.8.4
> plyr_1.4.1
> >
> > loaded via a namespace (and not attached):
> > [1] digest_0.4.2 tools_2.12.2
> >>
> >
> > Thanks.
> >
> > ______________________________________________
> > R-help_at_r-project.org
> 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.
>
>



R-help_at_r-project.org 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. Received on Sun 08 May 2011 - 00:21:52 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 May 2011 - 03:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive