2

I'm trying to read a .csv file like the following:

"Name", "Address"
"Me", "My address, City, State"

When I try

read.csv.sql(file = "myFile.csv", sql = "select * from file")

I get an error:

Error in .local(conn, name, value, ...) :   
  RS_sqlite_import: myFile.csv line 2 expected 2 columns of data but found 4

It seems like read.csv.sql is unable to recognize that the address record in my .csv file is one observation (rather than 3, given the commas). Is there any way to avoid this problem? I looked at the help file for read.csv.sql, but it doesn't seem like there's an option that fixes this issue.

In reality, I have a large file and I want to only read a subset of the columns. If there is another tool available within R, I'm happy to use that instead of read.csv.sql.

Jaap
  • 81,064
  • 34
  • 182
  • 193
random_forest_fanatic
  • 1,232
  • 1
  • 12
  • 30
  • Does adding `quote = "\"'"` help? – Jaap Sep 26 '15 at 06:06
  • @Jaap Unfortunately no; it seems that quote is not an argument to read.csv.sql. – random_forest_fanatic Sep 26 '15 at 12:10
  • This is handled by using the `filter=` argument. This is discussed (i) in `?read.csv.sql` , (ii) in the `file.format` argument documentation of `sqldf` and (iii) in example 13 in the sqldf README shown at the bottom of the home page: https://github.com/ggrothendieck/sqldf – G. Grothendieck Sep 26 '15 at 13:17

0 Answers0