grep_read: Efficiently read and filter lines from one or more files using grep, returning a data.table.
grep_read(
files = NULL,
path = NULL,
file_pattern = NULL,
pattern = "",
invert = FALSE,
ignore_case = FALSE,
fixed = FALSE,
show_cmd = FALSE,
recursive = FALSE,
word_match = FALSE,
show_line_numbers = FALSE,
only_matching = FALSE,
nrows = Inf,
skip = 0,
header = TRUE,
col.names = NULL,
include_filename = FALSE,
show_progress = FALSE,
...
)A data.table with different structures based on the options:
Default: Data columns with original types preserved
show_line_numbers=TRUE: Additional 'line_number' column (integer) with source file line numbers
include_filename=TRUE: Additional 'source_file' column (character)
only_matching=TRUE: Single 'match' column with matched substrings
show_cmd=TRUE: Character string containing the grep command
Character vector of file paths to read.
Optional. Directory path to search for files.
Optional. A pattern to filter filenames when using the
path argument. Passed to list.files.
Pattern to search for within files (passed to grep).
Logical; if TRUE, return non-matching lines.
Logical; if TRUE, perform case-insensitive matching (default: TRUE).
Logical; if TRUE, pattern is a fixed string, not a regular expression.
Logical; if TRUE, return the grep command string instead of executing it.
Logical; if TRUE, search recursively through directories.
Logical; if TRUE, match only whole words.
Logical; if TRUE, include line numbers from source files. Headers are automatically removed and lines renumbered.
Logical; if TRUE, return only the matching part of the lines.
Integer; maximum number of rows to read.
Integer; number of rows to skip.
Logical; if TRUE, treat first row as header. Note that using FALSE means that the first row will be included as a row of data in the reading process.
Character vector of column names.
Logical; if TRUE, include source filename as a column.
Logical; if TRUE, show progress indicators.
Additional arguments passed to fread.