Skip to content

Commit d1f78a2

Browse files
committed
better handling of file read and write ops
1 parent 4679baa commit d1f78a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

data-raw/f477.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ source_files_s3 |> lapply(function(x) {
3232

3333
# MAIN LOOP
3434

35+
print(paste0("Downloading ", x, " from s3://", s3_bucket_name))
36+
3537
file_name <- basename(x)
3638
file_path <- paste0(data_dir, "/", source_prefix, "/", file_name)
3739

40+
system(paste0("touch ", file_path))
41+
3842
cori.db::get_s3_object(s3_bucket_name, x, file_path) # <= `x` includes source_prefix (i.e. "source")
3943

4044
print(paste0("Finished downloading ", file_path))
4145

4246
release_name <- gsub(".zip", "", basename(file_path))
4347
release_dir <- paste0(data_dir, "/", release_name)
4448

45-
print(paste0("Unzip release contents to ", release_dir))
4649
dir.create(release_dir, recursive = TRUE, showWarnings = FALSE)
50+
print(paste0("Unzip release contents to ", release_dir))
4751

4852
unzip_command <- sprintf("unzip -u %s -d %s", file_path, release_dir)
4953
print(unzip_command)
@@ -115,6 +119,9 @@ source_files_s3 |> lapply(function(x) {
115119
## Write csv state tables by release to a "clean" subdirectory (states)
116120
file_name <- gsub("_us_", paste0("_", tolower(st_abbr), "_"), file_name)
117121
file_path <- paste0(clean_states_dir, "/", file_name)
122+
123+
system(paste0("touch ", file_path))
124+
118125
result <- data.table::fwrite(dt_st, file_path)
119126

120127
stopifnot(file.exists(file_path))

0 commit comments

Comments
 (0)