Tuesday, April 30, 2019

fast reading of csv data using R



In order to quickly read specific rows from a csv, use RSQLite library in R



library(RSQLite)
library(DBI)
con <- dbConnect(RSQLite::SQLite(), "SQLite", dbname = "sample_db.sqlite")
dbWriteTable(con, name="sample_table", value=paste0(data_output_dir,"dm_full_temporal_tmp.csv"), 
             row.names=FALSE, header=TRUE, sep = "|",overwrite = T)
st <- Sys.time()
# Query your data as you like
yourData <- dbGetQuery(con, "SELECT * FROM sample_table where period in ('201810' , '201802') ")
Sys.time()-st

# 34 sec
dbDisconnect(con)

No comments:

Post a Comment

Loud fan of desktop

 Upon restart the fan of the desktop got loud again. I cleaned the desktop from the dust but it was still loud (Lower than the first sound) ...