Update 0-greeter-dbcreation.R
This commit is contained in:
parent
141a3ce511
commit
dbc6b36610
1 changed files with 21 additions and 3 deletions
|
@ -12,8 +12,9 @@ cat("\014") # Clear the console
|
||||||
box::use(
|
box::use(
|
||||||
magrittr[`%>%`]
|
magrittr[`%>%`]
|
||||||
,RSQLite
|
,RSQLite
|
||||||
,DBI
|
,DBI[dbConnect,dbDisconnect,dbWriteTable]
|
||||||
,here[here]
|
,here[here]
|
||||||
|
,readr
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,17 +26,34 @@ box::use(
|
||||||
|
|
||||||
# create database ---------------------------------------------------------
|
# create database ---------------------------------------------------------
|
||||||
|
|
||||||
mimicDB <- DBI$dbConnect(
|
mimicDB <- dbConnect(
|
||||||
RSQLite$SQLite()
|
RSQLite$SQLite()
|
||||||
,here("ML","data-unshared","mimicDB.sqlite")
|
,here("ML","data-unshared","mimicDB.sqlite")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# create labevents table
|
||||||
|
readr$read_csv_chunked(
|
||||||
|
here("ML","data-unshared", "labevents.csv")
|
||||||
|
,callback = function(chunk,dummy){
|
||||||
|
dbWriteTable(mimicDB, "labevents", chunk, append = TRUE)
|
||||||
|
}
|
||||||
|
,chunk_size = 10000
|
||||||
|
,col_types = "_d_ddTT_d______"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# create patient table
|
||||||
|
|
||||||
|
readr$read_csv(
|
||||||
|
here("ML","data-unshared","patients.csv")
|
||||||
|
) %>%
|
||||||
|
dbWriteTable(mimicDB,"patients", .)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# close database ----------------------------------------------------------
|
# close database ----------------------------------------------------------
|
||||||
|
|
||||||
DBI$dbDisconnect(mimicDB)
|
dbDisconnect(mimicDB)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue