read_textfile_compressed: Read text files as vector of lines or a table, supports...

View source: R/util_files.R

read_textfile_compressedR Documentation

Read text files as vector of lines or a table, supports compressed files

Description

Supported compression formats; .zip|.gz|.bz2|.xz|.7z|.zst|.lz4 Using this function with other compression formats, or any of these formats but with unlisted file extensions, will not work

Usage

read_textfile_compressed(
  file,
  as_table = FALSE,
  skip_empty_rows = FALSE,
  nrow = -1,
  datatable_skip = NULL,
  ...
)

Arguments

file

path to input file

as_table

boolean, TRUE = results from data.table::fread(), FALSE = results from readr::read_lines() (default)

skip_empty_rows

ignore empty rows (default: FALSE)

nrow

optionally, integer specifying to only read first N rows

datatable_skip

hardcoded parameter for datatable_skip (set NULL to ignore; default)

...

sent to data.table::fread()

Details

note; the archive R package has some bugs still so we try to use the readr package for common compression formats e.g. bug while reading ZIP files; "Error: The size of the connection buffer (131072) was not large enough". Related bugreport @ https://github.com/tidyverse/vroom/issues/361

note; another bug is with reading Zstd archives compressed with –long decompressing with current implementation results in; Error: archive_read.cpp:102 archive_read_open1(): Zstd decompression failed: Frame requires too much memory for decoding Related bugreport @ https://github.com/libarchive/libarchive/issues/1795

Value

NULL if path doesn't exist or file could not be read / decompressed (warnings/errors are silent)


ftwkoopmans/msdap documentation built on March 5, 2025, 12:15 a.m.