Skip to content

Commit

Permalink
revert to use data.table fread directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jul 31, 2023
1 parent e7521c9 commit 724077f
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,42 +57,6 @@ column_to_rownames <- function(.data, var) {
}

read_lines <- function(file) {
tmpdir <- tempdir()
FUN <- NULL
if (endsWith(file, ".tar")) {
FUN <- utils::untar
} else if (endsWith(file, ".zip")) {
FUN <- utils::unzip
}
if (!is.null(FUN)) {
fnames <- FUN(file, list = TRUE)
if (inherits(fnames, "data.frame")) {
fnames <- fnames[[1L]]
}
if (length(fnames) > 1L) {
cli::cli_abort("Compressed files containing more than 1 file are currently not supported.")
}
FUN(file, exdir = tmpdir)
decompFile <- file.path(tmpdir, fnames)
file <- decompFile
on.exit(unlink(decompFile), add = TRUE)
} else {
if (endsWith(file, ".gz")) {
FUN <- gzfile
} else if (endsWith(file, ".bz2")) {
FUN <- bzfile
} else if (endsWith(file, ".xz") || endsWith(file, ".lzma")) {
FUN <- xzfile
}
if (!is.null(FUN)) {
decompFile <- tempfile(tmpdir = tmpdir)
R.utils::decompressFile(file, decompFile,
ext = NULL, FUN = FUN, remove = FALSE
)
file <- decompFile
on.exit(unlink(decompFile), add = TRUE)
}
}
data.table::fread(
file = file, sep = "", header = FALSE,
colClasses = "character",
Expand Down

0 comments on commit 724077f

Please sign in to comment.