R/readData.R

#' Function that makes prompts to read in manifest files for openSpecimen 
#' 
#' @export
#' 
#' @return A dataframe with the manifest file
#' 
#' @examples
#' df <- readData()

readData <- function(){
  require(readxl)
  require(readr)
  data_loc <- readline("Where is the location of the data? ex: (/dcs01/static/data_sheet.xlsx) ")  
  data_type <- readline("Is the extension xlsx or csv? ")
  if(data_type == 'xlsx'){
    df <- read_excel(data_loc)
  } else if(data_type == 'csv'){
    df <- read_csv(data_loc)
  } else{
    print('invalid data type entered')
  }
  print(paste('Data type:', data_type))
  print(paste('Data location:', data_loc))
  return(as.data.frame(df))
}
syyang93/openSpec documentation built on May 16, 2019, 3:24 p.m.