[R] Reading in csv with footer

chuck.01 CharlieTheBrown77 at gmail.com
Mon Feb 13 07:07:03 CET 2012


I believe this should work

d <- read.table("foo.csv", header=T, sep=",", comment="T")

although its spitting back a warning... this used to work for me.  




Noah Silverman wrote
> 
> Hi,
> 
> I have a CSV file that is formatted well, except that the last line is a
> "summary" not is CSV format.
> 
> Toy example:
> 
> label_1, label_2, label_3
> 1,2,3
> 3,2,4
> 2,3,4
> Total Rows: 3
> 
> 
> When I try to import this into R with:  d <- read.table("foo.csv",
> header=T, sep=",")
> It fails to import properly because of the last line.
> 
> Currently, I have a shell script that strips the last line from the file,
> then it imports to R cleanly.  I don't like this extra layer of
> processing.
> 
> Is there a way to import something like this cleanly in R.
> 
> Thanks!
> 
> --
> Noah
> ______________________________________________
> R-help@ 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.
> 


--
View this message in context: http://r.789695.n4.nabble.com/Reading-in-csv-with-footer-tp4382441p4382980.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list