Zohdsi,
Truth is, I confused myself in the answer too, sorry. I was talking about fread()
instead of LoadVocabFromCsv()
.
What worked for me was to copy the code from LoadVocabFromCsv()
. If you just enter this in the R console:
> ETLSyntheaBuilder::LoadVocabFromCsv
You get the code of the function:
function (connectionDetails, cdmSchema, vocabFileLoc, bulkLoad = FALSE)
{
csvList ← c(“concept.csv”, “vocabulary.csv”,
“concept_ancestor.csv”, “concept_relationship.csv”,
“relationship.csv”, “concept_synonym.csv”,
“domain.csv”, “concept_class.csv”, “drug_strength.csv”)
fileList ← list.files(vocabFileLoc)
fileList ← fileList[which(tolower(fileList) %in% csvList)]
conn ← DatabaseConnector::connect(connectionDetails)
for (csv in fileList) {
vocabTable ← data.table::fread(file = paste0(vocabFileLoc,
“/”, csv), stringsAsFactors = FALSE, header = TRUE,
sep = “\t”, na.strings = “”)
vocabTable ← as.data.frame(vocabTable)
if (tolower(csv) == “concept.csv” || tolower(csv) ==
“concept_relationship.csv” || tolower(csv) ==
“drug_strength.csv”) {
vocabTable$valid_start_date ← as.Date(as.character(vocabTable$valid_start_date),
“%Y%m%d”)
vocabTable$valid_end_date ← as.Date(as.character(vocabTable$valid_end_date),
“%Y%m%d”)
}
writeLines(paste0("Loading: ", csv))
suppressWarnings({
DatabaseConnector::insertTable(conn, tableName = paste0(cdmSchema,
“.”, strsplit(csv, “[.]”)[[1]][1]),
data = as.data.frame(vocabTable), dropTableIfExists = FALSE,
createTable = FALSE, useMppBulkLoad = bulkLoad,
progressBar = TRUE)
})
}
on.exit(DatabaseConnector::disconnect(conn))
}
<bytecode: 0x000001eacefcb118>
<environment: namespace:ETLSyntheaBuilder>
So you can copy the code to create your own function equal to LoadVocabFromCsv()
, but with quote = ""
in the call to data.table::fread()
.
Hope that works for you.
Kind regards.