Skip to content

Commit

Permalink
use findstr on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rok-cesnovar committed Oct 16, 2020
1 parent d75f277 commit 546453c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions R/read_csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@ read_cmdstan_csv <- function(files,
} else if (metadata$method == "optimize") {
all_draws <- 1
}
if (os_is_windows()) {
fread_cmd <- paste0("findstr /b /v '#' ", output_file)
} else {
fread_cmd <- paste0("grep -v '^#' ", output_file)
}
suppressWarnings(
draws <- data.table::fread(
cmd = paste0("grep -v '^#' ", output_file),
cmd = fread_cmd,
select = col_select
)
)
Expand Down Expand Up @@ -380,9 +385,14 @@ read_csv_metadata <- function(csv_file) {
csv_file_info <- list()
inv_metric_rows <- 0
parsing_done <- FALSE
if (os_is_windows()) {
fread_cmd <- paste0("findstr /b /v '[#a-zA-Z]' ", output_file)
} else {
fread_cmd <- paste0("grep -v '^#' ", output_file)
}
suppressWarnings(
metadata <- data.table::fread(
cmd = paste0("grep '^[#a-zA-Z]' ", csv_file),
cmd = fread_cmd,
colClasses = "character",
stringsAsFactors = FALSE,
fill = TRUE,
Expand Down

0 comments on commit 546453c

Please sign in to comment.