Skip to content

Commit

Permalink
chore: fix broken test due to different dir path in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Aug 23, 2024
1 parent 60b3880 commit eb84a51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export_to_xpt <- function(.df, path, max_size_gb, file_prefix) {
total_rows <- nrow(.df)
chunk_counter <- 1
row_start <- 1
dir_path <- dirname(path)

while (row_start <= total_rows) {
# Binary search to find the maximum number of rows that fit within the size limit
Expand All @@ -188,9 +189,9 @@ export_to_xpt <- function(.df, path, max_size_gb, file_prefix) {

# Write the best fitting chunk to the final file
file_name <- sprintf("%s%d.xpt", file_prefix, chunk_counter)
path <- sub("\\/[^/]*$", "/", path)
path <- file.path(dir_path, file_name)

write_xpt(.df[row_start:best_fit, ], path = paste0(path, file_name), version = 5, name = file_prefix)
write_xpt(.df[row_start:best_fit, ], path = path, version = 5, name = file_prefix)

# Update counters
row_start <- best_fit + 1
Expand Down

0 comments on commit eb84a51

Please sign in to comment.