Hadley Wickham
2010-Apr-08 01:09 UTC
[R] Using read.table to read file created with read.table and qmethod = "escape"
df <- data.frame(a = "a\"b") write.table(df, "test.csv", sep = ",", row = F) Is there any to load test.csv into R correctly? I've tried the following:> read.table("test.csv", sep = ",")[1] V1 <0 rows> (or 0-length row.names) Warning message: In read.table("test.csv", sep = ",") : incomplete final line found by readTableHeader on 'test.csv'> read.table("test.csv", sep = ",", allowEscapes = T)[1] V1 <0 rows> (or 0-length row.names) Warning message: In read.table("test.csv", sep = ",", allowEscapes = T) : incomplete final line found by readTableHeader on 'test.csv' And I can't see any other options in read.table that would apply. Regards, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
Peter Ehlers
2010-Apr-08 07:36 UTC
[R] Using read.table to read file created with read.table and qmethod = "escape"
This worked for me in R 2.11.0 alpha: df <- data.frame(a = "a\"b", v = 4, z = "this is Z") write.csv(df, "test.csv", row.names = FALSE, quote = FALSE) read.csv("test.csv", quote = "") -Peter Ehlers On 2010-04-07 19:09, Hadley Wickham wrote:> df<- data.frame(a = "a\"b") > write.table(df, "test.csv", sep = ",", row = F) > > Is there any to load test.csv into R correctly? I've tried the following: > >> read.table("test.csv", sep = ",") > [1] V1 > <0 rows> (or 0-length row.names) > Warning message: > In read.table("test.csv", sep = ",") : > incomplete final line found by readTableHeader on 'test.csv' >> read.table("test.csv", sep = ",", allowEscapes = T) > [1] V1 > <0 rows> (or 0-length row.names) > Warning message: > In read.table("test.csv", sep = ",", allowEscapes = T) : > incomplete final line found by readTableHeader on 'test.csv' > > And I can't see any other options in read.table that would apply. > > Regards, > > Hadley > >-- Peter Ehlers University of Calgary