0

I am using the following code to import data into my program by SimulationID.

    args <- commandArgs(TRUE)
    j <- args[1]
    library(sqldf)
    
    select <- paste0("select * from file where SimulID=",j,"")
    data_sim3 <- read.csv.sql("data_sim3.csv", select)

    closeAllConnections()

The problem is that sometimes the import will fail:

Error in connection_import_file(conn@ptr, name, value, sep, eol, skip) : RS_sqlite_import: disk I/O error Calls: read.csv.sql ... dbWriteTable -> dbWriteTable -> .local -> connection_import_file Error: no such savepoint: dbWriteTable_45140_xkusezrrcf Execution halted

Is there a workaround to this problem? Or maybe there is another package. I looked into data.table which can import based on row number but would prefer to import based on value of column, SimulID. (Also, the file does not have to be saved as a csv, text will also work).

This is a reference: Select specified rows when importing CSV

Thank you.

thewan
  • 27
  • 4
  • I'm not able to replicate your error. It may be something in the structure of your `data_sim3.csv` file. How large is this file? Is there something that requires you to use sqldf? If not, why not just `data.table::fread(data_sim3.csv)[SimulID == j]` – langtang Feb 14 '22 at 16:47
  • That worked. Thanks! (It's around 4GB.) – thewan Feb 15 '22 at 04:00

0 Answers0