guess_delim: Guess the delimiter of a text file

View source: R/guess-delims.R

guess_delimR Documentation

Guess the delimiter of a text file

Description

Taken from code used in vroom::vroom() with automatic reading.

Usage

guess_delim(file, delims = c(",", "\t", "|", ";"), string = FALSE)

Arguments

file

Either a path to a file or character string (with at least one newline character).

delims

The vector of single characters to guess from. Defaults to: comma, tab, pipe, or semicolon.

string

Should the file be treated as a string regardless of newline.

Value

The single character guessed as a delimiter.

Source

https://github.com/tidyverse/vroom/blob/85143f7a417376eaf0e2037ca9575f637e4346c2/R/vroom.R#L288

Examples

guess_delim(system.file("extdata", "vt_contribs.csv", package = "campfin"))
guess_delim("ID;FirstName;MI;LastName;JobTitle", string = TRUE)
guess_delim("
a|b|c
1|2|3
")

campfin documentation built on Oct. 20, 2023, 5:06 p.m.