R/detectQuote.R

Defines functions detectQuote

Documented in detectQuote

detectQuote = function(filename, skip) {
  # data.table::fread has argument quote.
  # On some computers the quotes in the files are
  # not recognised, to catch this first try to check whether this is the case:
  quote = "\""
  Dtest = NULL
  try(expr = {Dtest = data.table::fread(input = filename,
                                        header = FALSE, sep = ",", skip = skip,
                                        nrows = 20, quote = quote)}, silent = TRUE)
  if (length(Dtest) == 0) {
    quote = ""
  } else {
    if (nrow(Dtest) <= 1) {
      quote = "" 
    }
  }
  return(quote)
}

Try the GGIRread package in your browser

Any scripts or data that you put into this service are public.

GGIRread documentation built on Oct. 25, 2024, 5:06 p.m.