View source: R/peek-guess-delim.R
| peek_guess_delim | R Documentation |
Guess the delimiter, quote character and decimal mark of a
delimited text file. The function splits each of the first
n lines by each candidate delimiter and selects the
delimiter that produces the most consistent number of fields.
The algorithm is adapted from the vroom package.
peek_guess_delim(
path,
delims = c(",", "\t", " ", "|", ":", ";"),
quotes = c("\"", "'"),
n = 1024
)
path |
path to the text file. |
delims |
character vector of candidate delimiters. |
quotes |
character vector of candidate quote characters. |
n |
number of lines to read for guessing (default 1024). |
a named list with elements:
the guessed delimiter character (or NULL)
the guessed quote character (or NULL)
the guessed decimal mark (or NULL)
f <- system.file(package = "fpeek",
"datafiles", "test-comma.csv")
peek_guess_delim(f)
f <- system.file(package = "fpeek",
"datafiles", "test-semicolon.csv")
peek_guess_delim(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.