Skip to content

Commit

Permalink
Merge pull request #887 from devinit/feature/update-crs
Browse files Browse the repository at this point in the history
Revert "OECD truncate" because table structure changes
  • Loading branch information
akmiller01 committed Jan 6, 2023
2 parents 704f38c + d97ac19 commit 13aff3d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions data_updates/R/load_mirrors.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ chunk_load_table = function(con, table.quote, filename, col.names, quote="\"", s
index = 0
message(filename)
file_con = file(description=filename, open="r", encoding=encoding)
table.exists = dbExistsTable(con, name = table.quote)
if(allow.overwrite & table.exists){
dbExecute(con, statement=paste0('TRUNCATE TABLE "', table.quote[1], '"."', table.quote[2], '"'))
}
repeat{
index = index + 1
dataChunk = read.delim(file_con, nrows=chunk.size, skip=0, header=(index==1), sep=sep, col.names=col.names, as.is=T, na.strings=c("\032",""),quote=quote)
dataChunk = dataChunk[rowSums(is.na(dataChunk)) != ncol(dataChunk),]
dbWriteTable(con, name = table.quote, value = dataChunk, row.names = F, overwrite=F, append=T, field.types=field.types)
dbWriteTable(con, name = table.quote, value = dataChunk, row.names = F, overwrite=((index==1) & allow.overwrite), append=((index>1) | !allow.overwrite), field.types=field.types)
if(nrow(dataChunk) != chunk.size){
break
}
Expand Down

0 comments on commit 13aff3d

Please sign in to comment.