Hi Christofer, You have embedded commas in your data structure. This is guaranteed to mess up a CSV read.
Jim On Sun, Sep 4, 2016 at 5:54 PM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > Hi again, > > I was trying to read a subset of Data from a CSV file using below code > as example : > > library(sqldf) > > Dat = structure(list(`col 1` = c(133261L, 133261L, 133262L, 133262L > ), `col 2` = structure(1:4, .Label = c("aaa1", "aaa2", "bbb1, bbb", > "bbb3, bbb"), class = "factor"), `col 3` = c(10.59, 10.56, 10.59, > 10.56), `col 4` = c(10.59, 10.56, 10.59, 10.56), `col 5` = c(10.59, > 10.56, 10.59, 10.56), `col 6` = structure(c(1L, 2L, 1L, 2L), .Label = > c("04-Jul-16", > "05-Jul-16"), class = "factor")), .Names = c("col 1", "col 2", > "col 3", "col 4", "col 5", "col 6"), class = "data.frame", row.names = c(NA, > -4L)) > Dat > > write.csv(Dat, "Dat.csv", quote = FALSE, row.names = FALSE) > > ReadName = '133261' > read.csv.sql("Dat.csv", sql = "select * from file where 'col 1' = ReadName") > > Loading required package: tcltk > Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : > line 1 did not have 7 elements > > This code generates above Error. Could you please help me with a > pointer where something went wrong? My actual CSV file is quite huge > so I cant read it as whole. However basic structure of my original > file is similar as above "Dat" > > Thanks for your time. > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.