This function allows batch reading of multiple tabulated text files n batch.
The files can be designed specifically, or, alternatively all files from a given directory can be read.
If package data.table is available, faster reading of files will be performed using the function fread
.
readTabulatedBatch(
query,
path = NULL,
dec = ".",
header = "auto",
strip.white = FALSE,
blank.lines.skip = TRUE,
fill = FALSE,
filtCol = 2,
filterAsInf = TRUE,
filtVal = 5000,
silent = FALSE,
callFrom = NULL,
debug = FALSE
)
This function returns a list of data.frames
(character) vector of file-names to be read, if "."
all files will be read (no matter what their extension might be)
(character) path for reading files, if NULL
or NA
the current directory will be used
(character, length=1) decimals to use, will be passed to fread
or read.delim
(character, length=1) path for reading files, if NULL
or NA
the current directory will be used, will be passed to fread
or read.delim
(logical, length=1) Strips leading and trailing whitespaces of unquoted fields, will be passed to fread
or read.delim
(logical, length=1) If TRUE
blank lines in the input are ignored. will be passed to fread
or read.delim
(logical, length=1) If TRUE
then in case the rows have unequal length, blank fields are implicitly filled, will be passed to fread
or read.delim
(integer, length=1) which columns should be used for filtering, if NULL
or NA
all data will be returned
(logical, length=1) filter as inferior or equal (TRUE
) or superior or equal threshold filtVal
(numeric, length=1) which numeric threshold should be used for filtering, if NULL
or NA
all data will be returned
(logical) suppress messages
(character) allow easier tracking of messages produced
(logical) display additional messages for debugging
If you want to provide a flexible pattern of ffile-names, this has to be done before calling this usntion, eg using grep
to provide an explicit collection of flles.
However, it is possible to read different files from different locations/directories, the length of path
must match the length of query
fread
, read.delim
, for reading batch of csv files : readCsvBatch
path1 <- system.file("extdata", package="wrMisc")
fiNa <- c("a1.txt","a2.txt")
allTxt <- readTabulatedBatch(fiNa, path1)
str(allTxt)
Run the code above in your browser using DataLab