I have a series of large zipped files that I have been unzipping to load directly into a MySQL database for querying from R.
I'll continue with this example (on x86_64 GNU/Linux):
> write.csv(iris, file = "iris.csv", row.names = FALSE, quote = FALSE)
> system("gzip iris.csv")
> list.files(pattern = "iris")
[1] "iris.csv" "iris.csv.gz"
I currently load the unzipped file in the following way:
> library(RSQLite)
> con <- dbConnect(RSQLite::SQLite(), dbname = "test_db")
> dbWriteTable(con, name = "iris", value = "iris.csv", field.types = list(Sepal.Length = "decimal(6, 2)", Sepal.Width = "decimal(6, 2)", Petal.Length = "decimal(6, 2)", Petal.Width = "decimal(6, 2)", Species = "varchar(15)"), row.names = FALSE)
[1] TRUE
I am wondering if it is possible to do a direct table write to the DB using the zipped file iris.csv.gz
?
EDIT:
I am aware of gzfile
but to my understanding its usage would necessitate bringing the file into memory before writing to the MySQL DB, something I am looking to avoid (correct me if I'm misunderstanding)